-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: Improve error messages for non-string templates in ConditionalRouter #10189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
@mpangrazzi nothing urgent 🙏 |
Pull Request Test Coverage Report for Build 19899324781Details
💛 - Coveralls |
| assert "Invalid template for output" in error_message | ||
| assert "string" in error_message | ||
| assert "Jinja2 template" in error_message | ||
| assert "2" in error_message or "2!" in error_message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused on this statement. When would 2! appear in the error message?
sjrl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment, otherwise looks good!
Why:
Replaces cryptic "Can't compile non template nodes" errors with actionable guidance when users provide non-string values (e.g.,
2instead of"2") as route outputs in ConditionalRouter.What:
_validate_template()to detect non-string templates before Jinja parsing_validate_routes()to show value type and suggest fixes (e.g., "use '2' instead of 2")How can it be used:
How did you test it:
Notes for the reviewer:
Error message improvements are backward compatible and only enhance user experience during initialization validation.