Commit b4652eb
Fix navigating ui.sub_pages in root page with remaining path (zauberzeug#5442)
This bug was uncovered while trying to solve zauberzeug#5437 with PR zauberzeug#5440: When
using `ui.run(root)` with `ui.sub_pages()`, clicking navigation links
which have a remaining path would crash with `KeyError: 'route'`. This
occurred because the root function is served through FastAPI's 404
exception handler rather than a registered route, so
`request.scope['route']` doesn't exist.
Changed `_other_page_builder_matches_path()` in `SubPagesRouter` to
safely access `request.scope['route']` using `.get()` instead of direct
dictionary access. When the route key is missing (indicating a 404
handler scenario), the method returns `False`. If the client was created
via the 404 handler, no routes matched the initial request, so there
cannot be other matching page builders. The early return avoids the
KeyError and allows navigation to proceed normally.
- [x] I chose a meaningful title that completes the sentence: "If
applied, this PR will..."
- [x] The implementation is complete.
- [x] Pytests have been added.
- [x] Documentation not necessary.
---------
Co-authored-by: Falko Schindler <[email protected]>1 parent 19d53f2 commit b4652eb
1 file changed
+3
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
| |||
0 commit comments