Fix patternToPath to throw when path parameter is missing#11111
Fix patternToPath to throw when path parameter is missing#11111jhonathanqz wants to merge 3 commits intoflutter:mainfrom
Conversation
|
Thanks for the contribution! You haven’t checked off any of the items in the PR checklist above, so I’m assuming this is a work in progress and am marking it as a Draft. Please review the checklist, updating the PR as appropriate, and when that’s complete please feel free to mark the PR as ready for review. |
ba1b480 to
997e269
Compare
There was a problem hiding this comment.
Code Review
This pull request modifies the patternToPath function to throw a GoException if a required path parameter is missing, preventing the creation of invalid URLs with "null" values. The change includes a new test to verify this fail-fast behavior, a version bump to 17.1.1 in pubspec.yaml, and an update to CHANGELOG.md.
chunhtai
left a comment
There was a problem hiding this comment.
code looks fine, but ci is not happy
| @@ -1,3 +1,7 @@ | |||
| ## 17.1.1 | |||
|
|
|||
There was a problem hiding this comment.
for go_router, please create a changelog entry in pending_changes
[go_router] Fix patternToPath to throw when path parameter is missing
Previously,
patternToPathwrote the literal string"null"into the generated URL when a path parameter required by the pattern was missing from thepathParametersmap. This produced invalid URLs and made debugging difficult. This PR makespatternToPaththrow aGoExceptionwith a clear message (e.g."Missing path parameter: bookId") when a required parameter is missing, so callers get fail-fast behavior instead of silently generating wrong URLs.List which issues are fixed by this PR. You must list at least one issue.
Changes in this PR:
lib/src/path_utils.dart:patternToPathnow throwsGoExceptionwhen a path parameter is missing.test/path_utils_test.dart: New testpatternToPath throws when path parameter is missing.pubspec.yaml: Version bumped to 17.1.1.CHANGELOG.md: Added 17.1.1 entry.Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3