Skip to content

Adding suffixes to duplicated sanitized param names#7

Open
kafkasl wants to merge 1 commit into
mainfrom
param-collisions
Open

Adding suffixes to duplicated sanitized param names#7
kafkasl wants to merge 1 commit into
mainfrom
param-collisions

Conversation

@kafkasl

@kafkasl kafkasl commented Jun 12, 2026

Copy link
Copy Markdown

Problem

sanitized_params converts original spec param names to Python identifiers
(camelCase → snake_case), but doesn't check for collisions.

If an operation defines both locationCode and location_code, both sanitize to location_code, and mk_sig raises when building the Signature making the entire client unusable, not just that operation.

Real-world case: Verda Cloud's:
GET /v1/instance-availability (and
GET /v1/instance-availability/{instance_type})

define both locationCodeand location_code as query params (legacy alias).

Minimal repro

spec_json = httpx.get('https://api.verda.com/v1/openapi.json', follow_redirects=True).json()
spec = SpecParser.from_openapi(dict2obj(spec_json))
OpenAPIClient(spec)  # ValueError: duplicate parameter name 'location_code'

Fix

Make sanitized_params collision-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

  • Params whose sanitized name equals their original name claim it first
    (location_code keeps location_code).
  • Renamed params append _ on collision (locationCodelocation_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.

@kafkasl kafkasl self-assigned this Jun 12, 2026
@kafkasl kafkasl added the bug Something isn't working label Jun 12, 2026
@kafkasl kafkasl requested a review from KeremTurgutlu June 12, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant