Skip to content

MockVWS drops path prefix from base URLs (urljoin bug) #2993

@adamtheturtle

Description

@adamtheturtle

Problem

MockVWS uses urljoin to build the URL patterns it intercepts, e.g.:

url_pattern = urljoin(base=base_url, url=f"{route.path_pattern}$")

Because route.path_pattern starts with / (e.g. /targets, /v1/query), Python's urljoin silently discards any path component in the base URL. So if a user configures MockVWS(base_vws_url="http://localhost/prefix"), the mock registers handlers at http://localhost/targets instead of http://localhost/prefix/targets.

The same issue affects base_vwq_url.

Impact

A client library fixed to use string concatenation (base_url.rstrip("/") + path) instead of urljoin (as done in vws-python#2867) will send requests to http://localhost/prefix/targets, which the mock won't intercept, causing ConnectionError.

This makes it impossible to write a positive integration test for path-prefix base URL support without bypassing MockVWS entirely.

Fix

Replace the urljoin call in the route-registration code with string concatenation:

url_pattern = base_url.rstrip("/") + route.path_pattern + "$"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions