bug: wrong route parameter name matched, but handler is correct
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Environment
Nitro: 2.9.6 with Nuxt 3.12.2
Node: v20.14.0
Reproduction
- https://stackblitz.com/edit/github-xnbwjb?file=server%2Froutes%2F%5BprestationId%5D%2Findex.put.ts
- Visit:
/plop
Describe the bug
Maybe related to #2349
When having different param names within the same folder:
server/api/prestations
├── [prestationId]
│ ├── index.patch.ts
│ └── order.post.ts
├── [slug].get.ts
└── index.get.ts
[slug].get.ts router param [slug] will be prestationId instead of slug
If I rename the [slug].get.ts to [alug].get.ts (before in alphabetical order) it will have the correct parameter. I haven't tested if in this situation the route [prestationId]/index.patch.ts will now have the wrong parameter names.
Additional context
No response
Logs
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the StackBlitz reproduction and server/routes/[prestationId]/index.put.ts, then inspect how the sibling [slug].get.ts route is generated and receives its parameter. Reproduce the /plop request and trace the route-building order. Done means parameter names remain correct regardless of sibling filename ordering, with regression coverage for the shown route tree.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxt, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100