Fix ENDPOINT_URL not exposed to Lua workers in nginx#219
Conversation
|
LGTM — the root cause (missing |
nginx strips env vars from Lua workers unless declared with the 'env'
directive. ENDPOINT_URL was missing from nginx.conf.template, so
os.getenv('ENDPOINT_URL') always returned nil — the GCS backend
detection in PRESIGN_PART never fired and presigned part PUTs to GCS
always used the wrong canonical resource (with subresources).
- Add 'env ENDPOINT_URL;' to nginx.conf.template so Lua can read it.
- In PRESIGN_PART, move the '%3A' encoding inside the GCS branch so
standard S3 backends (cloudserver, Scaleway) keep literal ':' and
subresources in the canonical resource, while GCS gets '%3A' and
no subresources — matching what each backend verifies.
- Remove test_presign_upload_part_encodes_colons_in_url: the '%3A'
encoding is GCS-specific and cannot be asserted in CI (cloudserver).
The end-to-end round-trip test covers correctness for cloudserver.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6efb914 to
b91ff11
Compare
| ) | ||
|
|
||
|
|
||
| def test_presign_multipart_full_round_trip(session, artifacts_url): |
There was a problem hiding this comment.
Three blank lines between test_presign_upload_part_encodes_special_chars_in_upload_id and test_presign_multipart_full_round_trip after the test removal — PEP 8 E303 expects two.
| def test_presign_multipart_full_round_trip(session, artifacts_url): | |
| def test_presign_multipart_full_round_trip(session, artifacts_url): |
— Claude Code
|
LGTM — clean bugfix. The missing |
Summary
os.getenv('ENDPOINT_URL')always returnednilin Lua because nginx strips env vars from workers unless explicitly declared with theenvdirective —ENDPOINT_URLwas missing fromnginx.conf.templatePRESIGN_PART(endpoint_url:find('googleapis', 1, true)) never matched; the else branch always ran, producing a canonical resource with?partNumber=N&uploadId=Xthat GCS rejectsChanges:
env ENDPOINT_URL;toconf/nginx.conf.templatesoos.getenv('ENDPOINT_URL')works in Lua workers%3Akey encoding inside theif googleapisbranch inPRESIGN_PART: GCS gets%3A+ no subresources; standard S3 backends (cloudserver, Scaleway) keep literal:+ subresources per V2 spectest_presign_upload_part_encodes_colons_in_url: the%3Aencoding is GCS-specific and cannot be asserted in CI (cloudserver);test_presign_multipart_full_round_tripcovers end-to-end correctnessTest plan
test.yml— cloudserver round-trip test)test-uploadinscality/action-artifacts🤖 Generated with Claude Code