Skip to content

Do not overwrite "path" and "root_path" scope keys#2352

Merged
Kludex merged 3 commits intomasterfrom
fix-path-on-mount
Dec 1, 2023
Merged

Do not overwrite "path" and "root_path" scope keys#2352
Kludex merged 3 commits intomasterfrom
fix-path-on-mount

Conversation

@Kludex
Copy link
Owner

@Kludex Kludex commented Nov 29, 2023

@Kludex Kludex added this to the Version 1.0 milestone Nov 29, 2023
@Kludex Kludex requested review from a team and abersheeran November 30, 2023 13:09
@Kludex Kludex marked this pull request as ready for review November 30, 2023 13:09
@Kludex
Copy link
Owner Author

Kludex commented Nov 30, 2023

I'm going to try to make this PR cleaner, but it already solves the problem.

@Kludex Kludex changed the title Do not overwrite "path" and "root_path" scope keys Do not overwrite "path" and "root_path" scope keys Nov 30, 2023
Copy link
Contributor

@frankie567 frankie567 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from my question above, LGTM! You have filled the holes I left in my previous PR :)

Still not convinced about the naming current_root_path and current_path, but that's minor 😄 Suggestion (not ideal): route_root_path / route_path.

"path_params": path_params,
"app_root_path": scope.get("app_root_path", root_path),
"root_path": root_path + matched_path,
"path": remaining_path,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to keep the original root_path and path in the child scope?

Copy link
Owner Author

@Kludex Kludex Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't they always there anyway? Those lines were just modifying them, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right. My point was if we were using this child_scope as the new scope for inner routers, but it seems actually that it's always merged with the root scope.

@Kludex Kludex force-pushed the fix-path-on-mount branch from 6ae76f3 to f684f3b Compare December 1, 2023 11:02
@Kludex Kludex requested a review from frankie567 December 1, 2023 11:03
@Kludex Kludex mentioned this pull request Dec 1, 2023
4 tasks
@Kludex
Copy link
Owner Author

Kludex commented Dec 1, 2023

@encode/maintainers can someone review this, please?

Copy link
Contributor

@abersheeran abersheeran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks very nice, I like the regular expressions here.

@Kludex Kludex merged commit e8f0dcd into master Dec 1, 2023
@Kludex Kludex deleted the fix-path-on-mount branch December 1, 2023 12:55
maartenbreddels added a commit to widgetti/solara that referenced this pull request Dec 5, 2023
path now includes root_path so we need a different way to
remove it. It seems like route_root_path gives this information.

See Kludex/starlette#2361
Kludex/starlette#2352
Kludex/starlette#1336
maartenbreddels added a commit to widgetti/solara that referenced this pull request Dec 8, 2023
path now includes root_path so we need a different way to
remove it. It seems like route_root_path gives this information.

See Kludex/starlette#2361
Kludex/starlette#2352
Kludex/starlette#1336
RobbeSneyders pushed a commit to spec-first/connexion that referenced this pull request Dec 29, 2023
Fixes the change in behaviour in starlette v0.33 via PR
[#2352](Kludex/starlette#2352)
edoakes added a commit to ray-project/ray that referenced this pull request Feb 12, 2024
FastAPI has fixed the broken starlette interaction in 0.109.2: https://fastapi.tiangolo.com/release-notes/#01092

Starlette handling of root_path has changed in 0.33.0: Kludex/starlette#2352. Prior to this, it was incorrectly stripping the root_path from the path field (which we need to mirror). Added compatibility logic to handle both of these.

---------

Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Co-authored-by: Lonnie Liu <95255098+aslonnie@users.noreply.github.com>
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.

Handling of scope["root_path"] and scope["path"] differs from ASGI spec

3 participants