Fix path parameter validation to work with dependency injection#110
Merged
stv8 merged 2 commits intopallets-eco:masterfrom Dec 22, 2025
Merged
Fix path parameter validation to work with dependency injection#110stv8 merged 2 commits intopallets-eco:masterfrom
stv8 merged 2 commits intopallets-eco:masterfrom
Conversation
Contributor
|
@LouisTrezzini thanks for the bug fix, let me play around and inspect this this week and we should be able to get it out! |
|
Hey @stv8 what are the odds you get this change out before Christmas? |
Contributor
|
@wontons I'll make it happen |
stv8
approved these changes
Dec 22, 2025
Contributor
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.
Summary
validate_path_params()to only validate actual path parameters from Flask routes, not injected dependenciesProblem
The
validate_path_params()function was attempting to validate all function parameters inkwargs, including dependencies injected by other decorators. This caused errors when using@validate()with dependency injection patterns, as the injected parameters couldn't be validated by Pydantic.See #49
Solution
Modified
validate_path_params()to userequest.view_argsto identify which parameters are actual path parameters from the Flask route. This ensures only URL path parameters are validated, while injected dependencies and other parameters are left untouched.Changes
validate_path_params()inflask_pydantic/core.pyto checkrequest.view_argsapp_with_path_param_route_and_injectorto test DI compatibilityTestPathIntParameterAndInjectortest class with two testsTest plan