Skip to content

Fix urljoin bug with base URL path prefixes#2994

Merged
adamtheturtle merged 3 commits intomainfrom
adamtheturtle/fix-urljoin-bugs
Feb 22, 2026
Merged

Fix urljoin bug with base URL path prefixes#2994
adamtheturtle merged 3 commits intomainfrom
adamtheturtle/fix-urljoin-bugs

Conversation

@adamtheturtle
Copy link
Member

@adamtheturtle adamtheturtle commented Feb 22, 2026

Summary

Replace urljoin() with string concatenation to preserve path prefixes in base URLs. This fixes an issue where MockVWS(base_vws_url="http://localhost/prefix") would incorrectly register handlers at http://localhost/targets instead of http://localhost/prefix/targets.

Add comprehensive tests for path prefix handling in both requests_mock and respx implementations. The fix ensures path prefixes are properly preserved when constructing URL patterns for the mock interceptors.

Test plan

  • ✅ New tests verify path prefix handling for VWS and VWQ endpoints
  • ✅ All 10 tests in TestCustomBaseURLs pass
  • ✅ Existing tests without path prefixes continue to work

🤖 Generated with Claude Code


Note

Low Risk
Small, localized change to URL-pattern construction plus additional tests; main risk is regressions in route matching for edge-case base URLs.

Overview
Fixes mock route registration when base_vws_url/base_vwq_url include a path prefix by replacing urljoin() with explicit base_url.rstrip("/") + route.path_pattern concatenation in both the requests (responses) and httpx (respx) decorators.

Adds coverage to ensure prefixed base URLs only intercept requests under the prefix (and not the root), and updates the httpx adapter to normalize request header casing; also adds an httpx test asserting the VuMark instances endpoint returns a bytes response successfully.

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

Replace urljoin with string concatenation in URL pattern construction to preserve path prefixes in base URLs. This fixes the issue where MockVWS(base_vws_url="http://localhost/prefix") would incorrectly register handlers at http://localhost/targets instead of http://localhost/prefix/targets.

Add tests for path prefix handling in both requests_mock and respx implementations.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Normalize httpx header keys to title case in _to_request_data so that
validators can find headers like Authorization and Content-Type, which
httpx stores as lowercase. This enables properly-authenticated requests
through the respx mock.

Add test_vumark_bytes_response to exercise the bytes response path in the
respx callback, which is only reachable via the vumark endpoint with valid
authentication.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@adamtheturtle adamtheturtle merged commit eaea57a into main Feb 22, 2026
106 checks passed
@adamtheturtle adamtheturtle deleted the adamtheturtle/fix-urljoin-bugs branch February 22, 2026 11:55
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