Skip to content

Raise error when registering duplicate routes#3086

Closed
Cyber-Vansh wants to merge 2 commits intopallets:mainfrom
Cyber-Vansh:fix-duplicate-routes
Closed

Raise error when registering duplicate routes#3086
Cyber-Vansh wants to merge 2 commits intopallets:mainfrom
Cyber-Vansh:fix-duplicate-routes

Conversation

@Cyber-Vansh
Copy link

Summary

Registering the same route multiple times currently fails silently. Werkzeug
continues using the first registered rule, which can lead to subtle bugs.

This change raises a ValueError when a duplicate route is registered.

Changes

  • Detect duplicate routes in Map.add
  • Raise an explicit exception on duplicate rule registration
  • Add test coverage for duplicate routes

Motivation

This makes routing errors visible early and aligns route handling with endpoint
duplication checks.

Fixes #3037

@ThiefMaster
Copy link
Member

What was the reason for opening another PR, considering there is already one (#3038)?

@davidism davidism closed this Jan 10, 2026
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding the same route twice will silently fail, should raise an exception instead

3 participants