Repository navigation
Conversation
🧪 Hands-on test plan (not run: external contributor)Commit Summary: Run the PR's new tests and the existing apigw unit tests. Then run an in-process matrix that drives LocalApigwService through the Flask test client with a stub Lambda runner and classifies each response body as BINARY or BASE64, comparing PR to merge base. Finally run real sam local start-api with BinaryMediaTypes image~1* and a Python 3.12 function to confirm PNG/JPEG bytes are returned decoded and text/pdf controls stay Base64. For a maintainer to check:
Needs cloud resources:
Planned checks (4):
Commands🤖 Automated hands-on test — not a review approval · model claude-opus-5.5 · commit History (3)
|
|
Revalidated
For the synthetic helper edges, parameters match and a slashless mocked MIME type returns True, as the plan notes. With an actual slashless Content-Type/Accept request, Werkzeug selects no matching MIME type and the response remains Base64 on both revisions. I left the existing malformed-type and case-sensitive behavior unchanged. All validation ran locally with dummy credentials. The PR description now has the current validation results. Could a maintainer approve the queued workflows when convenient? |
|
Merged the latest On The upstream workflows still need maintainer approval before they can run. |
Which issue(s) does this change fix?
Reproduced on
developat003fb8bd6969ffd93c78336a9a9c86eef0ade041. Related work: #8018 addresses request-body encoding.Why is this change necessary?
With
BinaryMediaTypes: ["image/*"], a REST API Lambda proxy response withContent-Type: image/pngandisBase64Encoded: truereaches the client as Base64 text insam local start-api. The response check only recognizes exact MIME types and*/*.API Gateway supports wildcard binary media types. The local response path should recognize a matching subtype range as well.
How does it address the issue?
Recognize the selected MIME type's
type/*range in the response decoding predicate. Add unit coverage for matching ranges, mismatches, a false encoding flag, and a missing selection. Functional tests drive the real local Flask service with a stub Lambda runner, checking PNG, JPEG and PDF bytes along with exact-match and*/*controls.What side effects does this change have?
Matching subtype ranges now enable binary response decoding when
isBase64Encodedis true.Validation
Revalidated at
f8491ebafter mergingdevelopat003fb8b. The response patch remains unchanged.make prpassed, with 9,662 unit tests passed, 28 skipped and coverage 94.20%. All local unit tests plus the functional regression also passed: 1,354 tests.--network noneand dummy credentials.sam local start-apiwith a Python 3.12.15 arm64 Lambda container:image~1*returns the original PNG bytes with this patch and Base64 text on the base. Text/plain, a false encoding flag and an unmatched Accept remain Base64 in both revisions (4 checks per revision).The local CLI/container checks used dummy credentials and Python socket guards. No live AWS comparison or deployment was run.
Mandatory Checklist
make prpassesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.