Skip to content

Return 404 for requests to paths the Flask mock does not serve - #3384

Open
adamtheturtle wants to merge 1 commit into
mainfrom
adamtheturtle/issue-3368
Open

Return 404 for requests to paths the Flask mock does not serve#3384
adamtheturtle wants to merge 1 commit into
mainfrom
adamtheturtle/issue-3368

Conversation

@adamtheturtle

Copy link
Copy Markdown
Member

validate_request is a before_request hook, and Flask runs those before it raises a routing error, so requests matching no route reached validate_keys, which unpacked an empty generator and raised ValueError — crashing the Flask and Docker backends for any authenticated request to an unknown path or to a known path with an unserved method.

This skips validation when Flask has matched no route (request.url_rule is None), leaving Flask to raise its own routing error: 404 for an unknown path, as real Vuforia returns, and 405 for an unserved method.

Tests use the Flask test client, since responses intercepts only the paths the app routes; a further test covers the unauthenticated probe the Docker health check makes, which now sees 404 instead of 401 (both are in its accepted set). The new behaviour and the unverified response bodies are documented in the differences doc.

Closes #3368

🤖 Generated with Claude Code

The Flask app's ``validate_request`` before_request hook ran for requests
which match no route, because Flask runs before_request handlers before it
raises the routing error. ``validate_keys`` then unpacked an empty generator
and raised a ``ValueError``, so any authenticated request to an unknown path,
or to a known path with a method it does not serve, crashed the Flask and
Docker backends.

Skip validation when Flask has matched no route, so Flask raises its own
routing error: 404 for an unknown path, as real Vuforia returns, and 405 for
an unserved method.

Closes #3368

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.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.

The Flask backend crashes on requests to unrouted paths and methods

1 participant