Skip to content
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

Confusing 404s when combining multiple rest parameters, slugs and param matchers #13106

Open
arnolicious opened this issue Dec 4, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@arnolicious
Copy link

Describe the bug

Hi everyone,
Honestly I'm not quite sure where to start, I've hit a use case where the routing isn't quite working how I think it should be working, so I would very tentatively call it a bug.

Scenario

The page I'm concerned about is at the path event/:id and below.

  1. There can be any number of previous path segments before hand, thus I added a [...path] before.
  2. The "event" string could actually be multiple different strings, event | project | job, so i have a param matcher for that
  3. The id being a slug is quite self explanatory
  4. Then the main page of the event is actually under event/:id/overview, so I've got that redirect in event/[id]/+page.ts
  5. Now if a path like event/:id/invalid gets hit, I want to display an error inside of the event page, so event/[id]/+error.svelte, thus the event/:id/[...catchall]/+page.ts.

Entire Structure:
image

Expected Behaviour

Sveltekit hits the event/:id/[...catchall]/+page.ts, throws the 404 that gets caught in the event/[id]/+error.svelte.

Actual Behaviour

The entire route gets 404-ed and the generic 404 message gets displayed.

Now it does actually work as expected, if either one of these modifications is made:

  • /[id]/ -> /1/ : If the id is not a slug, but a literal 1 (for example to match the hrefs), it does work correctly (the red outline around the 404 message shows that it's the correct +error.svelte
  • /[event=eventSlug]/ -> /event/ : If the event segment does not have a param matcher, it also works correctly

Addendum

I also think I experienced more weirdness, where the routing wouldn't behave the same when built on windows compare to linux, where on my local windows machine it would work as expected and on linux rest parameters would get hit instead of other explicit paths on the same level, but I haven't really been able to reproduce that so far.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-win19u?file=src%2Fparams%2FidParam.ts

Logs

No response

System Info

Stackblitz:
  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @sveltejs/adapter-auto: ^3.0.0 => 3.3.1 
    @sveltejs/kit: ^2.9.0 => 2.9.0 
    @sveltejs/vite-plugin-svelte: ^5.0.0 => 5.0.1 
    svelte: ^5.0.0 => 5.5.2 
    vite: ^6.0.0 => 6.0.2

Local Machine:
  System:
    OS: Windows 11 10.0.26120
    CPU: (16) x64 AMD Ryzen 7 5800X3D 8-Core Processor
    Memory: 11.15 GB / 31.91 GB
  Binaries:
    Node: 20.9.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.2.5 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.10.2 - ~\AppData\Local\pnpm\pnpm.EXE
    bun: 1.1.38 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Chromium (131.0.2903.36)
    Internet Explorer: 11.0.26100.1
  npmPackages:
    @sveltejs/adapter-auto: ^3.0.0 => 3.3.1
    @sveltejs/kit: ^2.9.0 => 2.9.0
    @sveltejs/vite-plugin-svelte: ^5.0.0 => 5.0.1
    svelte: ^5.0.0 => 5.5.2
    vite: ^6.0.0 => 6.0.2

Severity

blocking all usage of SvelteKit

Additional Information

No response

@eltigerchino eltigerchino added the bug Something isn't working label Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants