Skip to content

Conversation

@LouisTrezzini
Copy link

@LouisTrezzini LouisTrezzini commented Oct 31, 2025

Summary

  • Fixed validate_path_params() to only validate actual path parameters from Flask routes, not injected dependencies
  • Added tests to verify path parameter validation works correctly with dependency injection decorators

Problem

The validate_path_params() function was attempting to validate all function parameters in kwargs, 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 use request.view_args to 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

  • Updated validate_path_params() in flask_pydantic/core.py to check request.view_args
  • Added test fixture app_with_path_param_route_and_injector to test DI compatibility
  • Added TestPathIntParameterAndInjector test class with two tests

Test plan

  • Existing tests pass
  • New tests verify path params work with DI decorators
  • Path parameter validation still works correctly
  • Invalid path parameters are still caught and reported

@stv8 stv8 self-requested a review November 3, 2025 15:21
@stv8
Copy link
Contributor

stv8 commented Nov 3, 2025

@LouisTrezzini thanks for the bug fix, let me play around and inspect this this week and we should be able to get it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants