You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note how /healthcheck now behaves differently on the two subdomains. On "static", we now get back the on_static endpoint, and on "foo" we still get back the on_healthcheck endpoint.
I see the same behavior with the latest version of werkzeug (3.0.3 at time of writing).
Summary
Is this change in behavior intentional? The PR #2433 just describes this as a faster matcher, it doesn't say anything about a change in behavior.
Is there some way of configuring a route across all subdomains that takes precedence over the subdomain specific /<path:filename> rule in my example?
Workaround
I don't have a great workaround for this. I can get close to the pre-werkzeug 2.2 behavior by adding a 3rd rule specifically for the "static" subdomain:
The text was updated successfully, but these errors were encountered:
davidism
changed the title
Regression in Werkzeug 2.2 (State Machine Matcher): priority between complex rule with subdomain and simple rule for all subdomains changes
url matching order changed since 2.2
Jul 16, 2024
davidism
changed the title
url matching order changed since 2.2
url matching order changed versus 2.2
Jul 16, 2024
(Sorry for the convoluted title: I don't know the right vocabulary for this.)
I noticed when upgrading to Werkzeug 2.2+, two of my routing rules have swapped priority.
Sample application
Here's a simple werkzeug application. The important part is the 2 rules:
cat server.py
Before (on werkzeug <2.2)
Run the server:
Note how /healthcheck behaves the same on both the "static" subdomain, and a different subdomain "foo":
"static" subdomain:
"foo" subdomain:
After (werkzeug 2.2+)
Note how /healthcheck now behaves differently on the two subdomains. On "static", we now get back the
on_static
endpoint, and on "foo" we still get back theon_healthcheck
endpoint."static" subdomain:
"foo" subdomain:
I see the same behavior with the latest version of werkzeug (3.0.3 at time of writing).
Summary
Is this change in behavior intentional? The PR #2433 just describes this as a faster matcher, it doesn't say anything about a change in behavior.
Is there some way of configuring a route across all subdomains that takes precedence over the subdomain specific
/<path:filename>
rule in my example?Workaround
I don't have a great workaround for this. I can get close to the pre-werkzeug 2.2 behavior by adding a 3rd rule specifically for the "static" subdomain:
Rule('/<path:filename>', endpoint=self.on_static, subdomain="static"), Rule('/healthcheck', endpoint=self.on_healthcheck, subdomain="<subdomain>"), +Rule('/healthcheck', endpoint=self.on_healthcheck, subdomain="static"),
But this behaves a bit differently: there's no
subdomain
argument passed to my endpoint handler.Environment:
@pgjones, since you wrote the new matcher
The text was updated successfully, but these errors were encountered: