Adding suffixes to duplicated sanitized param names#7
Open
kafkasl wants to merge 1 commit into
Open
Conversation
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.
Problem
sanitized_paramsconverts original spec param names to Python identifiers(camelCase → snake_case), but doesn't check for collisions.
If an operation defines both
locationCodeandlocation_code, both sanitize tolocation_code, andmk_sigraises when building theSignaturemaking the entire client unusable, not just that operation.Real-world case: Verda Cloud's:
GET /v1/instance-availability(andGET /v1/instance-availability/{instance_type})define both
locationCodeandlocation_codeas query params (legacy alias).Minimal repro
Fix
Make
sanitized_paramscollision-aware. If there's a param that matches the exact original name, use that. The rest get a_as suffix. I was considering simply dropping the duplicates because they are probably just deprecreated, but they would be unusable, happy to change that or listen to other solutions @KeremTurgutlu(
location_codekeepslocation_code)._on collision (locationCode→location_code_).Only the Python-side identifier changes; the original name is still sent
on the wire (same mechanism as the existing keyword handling, e.g.
class_).Non-colliding specs are unaffected.