Repository navigation
fix(parser,event_handler): accept the list values VPC Lattice V2 sends in headers and query strings - #8793
Merged
Conversation
…s in headers and query strings
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8793 +/- ##
========================================
Coverage 97.18% 97.18%
========================================
Files 323 323
Lines 16537 16542 +5
Branches 1494 1495 +1
========================================
+ Hits 16071 16076 +5
Misses 326 326
Partials 140 140 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue number:
closes #8773
closes #8776
Summary
Changes
VPC Lattice sends every
headersandqueryStringParametersvalue in a V2 event as a list, even when there is one value. Two places in the library still assumed plain strings:VpcLatticeV2Modeltyped both fields asdict[str, str], so the model andVpcLatticeV2Enveloperejected every real event with aValidationError. Both aredict[str, list[str]]now, descriptions and examples updated. Strict list, nostrunion: the service never sends strings, and a union would push anisinstancecheck into every handler that reads a header.OpenAPIRequestValidationMiddlewareread Content-Type with.strip()in two places, soVPCLatticeV2Resolver(enable_validation=True)crashed withAttributeError: 'list' object has no attribute 'strip'on any route with aBody()orForm()parameter. A small_get_content_typehelper takes the first element when the header is a list; the other resolvers keep passing strings through it unchanged.Tests: the V2 parser tests now use
vpcLatticeV2EventWithHeaders.json, which has the list shape, plus three new ones againstvpcLatticeV2EventWithQueryString.json, the event captured from a live target group (#8572): model, envelope, and one asserting that the plain-string fixture is rejected. On the resolver side, three functional tests run validation on the captured event with a JSON body, a form body and an invalid body (422, not a crash). All ten fail ondevelop, pass here. No fixture was changed;vpcLatticeV2Event.jsonis still used by the data class and resolver tests, where the string shape does not matter.Reported by @Manishram-ai (#8773, first fix in #8774) and @AtulJoshi1206 (#8776, #8777).
User experience
VpcLatticeV2Modeland the envelope parse real V2 events, and header and query string values come back as lists,{"header1": ["value1", "value2"]}. Request validation works onVPCLatticeV2Resolverlike on every other resolver.Visible change: an event with plain string values for those fields, a shape VPC Lattice does not send, fails validation now. Hand-written test events with that shape need the list form.
Verification
tests/unit/parser,tests/unit/data_classes,tests/functional/event_handler,tests/functional/parser: 1719 passed.mypyclean on both packages,xenonwithin limits,ruffclean. The two list-valued fixtures came from a real VPC Lattice V2 target group, so the shape under test is the service's, not a mock. Written with an AI assistant; I ran everything above myself.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.