Skip to content

Reject Model Target requests with a non-integer Content-Length - #3442

Merged
adamtheturtle merged 1 commit into
mainfrom
adamtheturtle/model-target-content-length
Aug 13, 2026
Merged

Reject Model Target requests with a non-integer Content-Length#3442
adamtheturtle merged 1 commit into
mainfrom
adamtheturtle/model-target-content-length

Conversation

@adamtheturtle

Copy link
Copy Markdown
Member

Towards #3400.

What

#3400 points out that the six cross-cutting test modules which the endpoint fixture feeds do not cover the Model Target Web API. The model_target_endpoint fixture now covers the Authorization header and the invalid-body concerns, but not Content-Length.

The mock did no Content-Length handling at all for Model Target routes, so a header which is not an integer reached the bearer token check and got a 401 where real Vuforia gives a 400.

Real Vuforia behavior

Model Target routes are served from vws.vuforia.com, behind the same load balancer as the VWS API, and a non-integer Content-Length is rejected before the request reaches any API. This is verifiable without an access token, so unlike most Model Target work it is not blocked by the revoked OAuth2 credentials (#3441). Observed for POST /modeltargets/datasets, POST /modeltargets/advancedDatasets, the status, download and delete routes for both dataset types, and POST /oauth2/token:

400 | Server: awselb/2.0, Content-Type: text/html, Connection: close
    | '<html>\r\n<head><title>400 Bad Request</title></head>\r\n...'

That is the same response the VWS API gives, which the mock already models as ContentLengthHeaderNotIntError.

A Content-Length which is too small truncates the body. The Model Target Web API does not sign the request body, so it has no reason to notice the truncation before it looks at the Authorization header, and it returns the usual 401 / no Bearer token. The mocks already matched.

Changes

  • Every Model Target route, and the OAuth2 token route, returns the load balancer's 400 response for a Content-Length header which is not an integer, reusing ContentLengthHeaderNotIntError so the body and headers stay in one place.
  • TestContentLength in tests/mock_vws/test_model_target_web_api.py, running over every Model Target endpoint via the model_target_endpoint fixture, plus a case for the OAuth2 token endpoint which that fixture excludes.
  • A Content-Length which is too large is left uncovered, as it is for the VWS API: real Vuforia waits for the body it was promised and then times out, which is too slow for a test. This is noted in the test class docstring.

Testing

TestContentLength passes against the real Vuforia, in-memory mock and Docker-in-memory backends. The whole non-real suite passes: 1469 passed, 22 skipped.

🤖 Generated with Claude Code

Towards #3400.

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.

1 participant