Skip to content

fix(matcher): add workaround hint to invalid params warning#2662

Open
shanliuling wants to merge 1 commit intovuejs:mainfrom
shanliuling:fix/catch-all-redirect-warning
Open

fix(matcher): add workaround hint to invalid params warning#2662
shanliuling wants to merge 1 commit intovuejs:mainfrom
shanliuling:fix/catch-all-redirect-warning

Conversation

@shanliuling
Copy link

@shanliuling shanliuling commented Mar 16, 2026

What is the problem?

When using a catch-all route with a named redirect like:

{
  path: '/:pathMatch(.*)*',
  redirect: { name: 'HOME' }
}

Users see a warning:
Discarded invalid param(s) "pathMatch" when navigating.

The warning message doesn't explain how to fix the issue.

How did I fix it?

Enhanced the warning message to include a helpful workaround hint:
If you are using a catch-all route with a named redirect, pass an empty params object: redirect: { name: '...', params: {} }.

This matches the workaround suggested by @posva in the issue comments.

How was this tested?

  • Updated the existing test in packages/router/__tests__/warnings.spec.ts to match the new warning format
  • The test now also checks for the presence of the workaround hint

Closes #1617

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved warning messages for invalid route parameters to include additional guidance about catch-all routes and parameter handling, helping developers resolve configuration issues more effectively.

The warning for discarded invalid params now includes a helpful hint
for users encountering the catch-all route redirect scenario.
@netlify
Copy link

netlify bot commented Mar 16, 2026

Deploy Preview for vue-router canceled.

Name Link
🔨 Latest commit e5667ca
🔍 Latest deploy log https://app.netlify.com/projects/vue-router/deploys/69b7f68a2766e6000847e24d

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ee3a5f41-7bb3-4154-a512-b1e33fe666a6

📥 Commits

Reviewing files that changed from the base of the PR and between 47f0334 and e5667ca.

📒 Files selected for processing (2)
  • packages/router/__tests__/warnings.spec.ts
  • packages/router/src/matcher/index.ts

📝 Walkthrough

Walkthrough

The changes enhance the warning message displayed when invalid parameters are discarded during navigation to catch-all routes with named redirects. A test expectation is updated to verify the improved warning guidance is correctly emitted.

Changes

Cohort / File(s) Summary
Warning Message Enhancement
packages/router/src/matcher/index.ts
Updated the invalid params warning to include additional guidance about catch-all routes with named redirects and an example of passing an empty params object.
Test Update
packages/router/__tests__/warnings.spec.ts
Removed trailing whitespace from expected warning string and added new expectation to verify the catch-all route workaround hint is displayed.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

A catch-all route hops with delight,
No more warnings blocking its flight,
With hints now clear, like carrots so bright,
The path forward guides users right! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding a workaround hint to the invalid params warning message for the catch-all route scenario.
Linked Issues check ✅ Passed The PR successfully addresses issue #1617 by enhancing the warning message with a workaround hint and updating tests to validate the new message format.
Out of Scope Changes check ✅ Passed All changes are directly related to the objective: modifying the warning message in matcher/index.ts and updating corresponding tests in warnings.spec.ts.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can get early access to new features in CodeRabbit.

Enable the early_access setting to enable early access features such as new models, tools, and more.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warning of invalid param for catch all route with named route redirect

2 participants