Skip to content

Comments

Fix validators when base URL has a path prefix#2996

Merged
adamtheturtle merged 1 commit intomainfrom
adamtheturtle/add-tornado-support
Feb 22, 2026
Merged

Fix validators when base URL has a path prefix#2996
adamtheturtle merged 1 commit intomainfrom
adamtheturtle/add-tornado-support

Conversation

@adamtheturtle
Copy link
Member

@adamtheturtle adamtheturtle commented Feb 22, 2026

Summary

  • Fixes validate_target_id_exists breaks with base URL path prefix #2995: when MockVWS or MockVWSForHttpx is configured with a base_vws_url containing a path prefix (e.g. https://example.com/prefix), the full request path (including prefix) was passed to validators and route handlers unchanged
  • Path-length-based validators (validate_target_id_exists, validate_keys, validate_name_*) incorrectly treated the extra path segments as part of the API path, causing spurious errors
  • Fix: strip the base URL path prefix from the request path in _wrap_callback (requests mock) and _make_callback/_to_request_data (respx mock) before constructing RequestData, so all validators and handlers always see the API-relative path

Test plan

  • Added test_vws_operations_work_with_path_prefix to both test_requests_mock_usage.py and test_respx_mock_usage.py
  • These tests fail before the fix (401 instead of 200) and pass after
  • All existing TestCustomBaseURLs tests continue to pass

🤖 Generated with Claude Code


Note

Low Risk
Small, localized change to request path normalization in mock callbacks plus targeted regression tests; low chance of unintended impact outside prefixed base-URL usage.

Overview
Fixes MockVWS (responses/requests) and MockVWSForHttpx (respx/httpx) when base_vws_url/base_vwq_url include a path prefix by stripping the parsed base_url path from incoming request paths before building RequestData, so route handlers and path-based validators see consistent API-relative paths.

Adds regression tests for both clients that perform an authenticated GET /targets against a prefixed base URL and assert a successful empty result set.

Written by Cursor Bugbot for commit 7775aed. This will update automatically on new commits. Configure here.

When MockVWS or MockVWSForHttpx is configured with a base_vws_url
containing a path prefix (e.g. https://example.com/prefix), strip the
prefix from the request path before passing it to validators and route
handlers. Previously, validators performing path-length checks (e.g.
validate_target_id_exists, validate_keys, validate_name_*) received the
full prefixed path and incorrectly parsed it, causing spurious errors
such as UnknownTarget for endpoints that take no target ID.

Fixes #2995.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@adamtheturtle adamtheturtle merged commit 21d7e70 into main Feb 22, 2026
106 checks passed
@adamtheturtle adamtheturtle deleted the adamtheturtle/add-tornado-support branch February 22, 2026 13:17
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.

validate_target_id_exists breaks with base URL path prefix

1 participant