Skip to content

[PR] Reject overlapping route methods for same path and host - #940

Open
dajiaohuang wants to merge 1 commit into
AnswerDotAI:mainfrom
dajiaohuang:fix-route-method-shadowing-924
Open

dajiaohuang wants to merge 1 commit into
AnswerDotAI:mainfrom
dajiaohuang:fix-route-method-shadowing-924

Conversation

@dajiaohuang

Copy link
Copy Markdown

Related Issue
Fixes #924

Proposed Changes
When same-path, same-host sibling routes have overlapping methods, Starlette's first-match routing can silently shadow a later handler (for example, a default GET/POST route followed by an explicit POST route). FastHTML.add_route now raises ValueError and lists the overlap instead. Same-name/method replacement remains supported, as do disjoint methods and routes on different hosts.

The nbdev source notebook and generated module are synchronized; the API docstring describes the new conflict behavior.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I am aware that this is an nbdev project, and I have edited, cleaned, and synced the source notebooks instead of editing .py or .md files directly.

Additional Information

  • python -m pytest --noconftest -p no:cacheprovider tests/test_routing.py: 3 passed on Python 3.11.15; synthetic route registrations only.
  • nbdev-export --path nbs/api/00_core.ipynb and nbdev-clean --fname nbs/api/00_core.ipynb completed. git diff --check passed.
  • The full notebook/project suite was not run; no unrelated notebooks were executed.

This branch has not been deployed

No deployments
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.

@rt default all-method registration shadows sibling handlers on same path

1 participant