Fix false RouterPathParamsModifiedError when renaming path-versioned endpoints#358
Merged
Fix false RouterPathParamsModifiedError when renaming path-versioned endpoints#358
Conversation
…ersion} prefix When api_version_location="path", the api_version param appears in route paths but not in dependant.path_params, causing a false positive when validating path param consistency on endpoint renames. Thread api_version_parameter_name through generate_versioned_routers and _EndpointTransformer down to _apply_endpoint_had_instruction, which now discards the version param directly instead of inferring it via regex. Fixes #357 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #358 +/- ##
=======================================
Coverage 99.84% 99.84%
=======================================
Files 72 72
Lines 5645 5663 +18
Branches 358 359 +1
=======================================
+ Hits 5636 5654 +18
Misses 9 9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Code reviewFound 1 issue:
cadwyn/tests/test_router_generation.py Lines 264 to 276 in 3d02910 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
…nferring it Replace the indirect `_api_version_path_param_name` approach with explicitly passing `api_version_location` to `_EndpointTransformer` and `_apply_endpoint_attributes_to_route`. This makes the path param filtering logic clearer by checking `api_version_location == "path"` directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
When
api_version_location="path", the{api_version}placeholder appearsin route paths but not in
dependant.path_params— FastAPI doesn't treat itas an endpoint param. This caused a false positive in the path param
consistency check when using
.had(path=...)to rename an endpoint.Instead of inferring the version-managed param via regex diff against the
original route path, thread
api_version_parameter_namefromCadwynthrough
generate_versioned_routers→_EndpointTransformer→_apply_endpoint_had_instruction, where it is discarded from the candidateparam set before comparison.
Fixes #357