Skip to content

Cloud query clients raise JSONDecodeError for documented empty 4xx responses #3093

Description

@adamtheturtle

Summary

Vuforia documents that failed Cloud Query requests may return an arbitrary body or no body at all. The sync and async query clients only special-case 413, the max-results text, and 5xx responses before unconditionally parsing response.text as JSON.

As a result, a documented empty/non-JSON 4xx response raises json.JSONDecodeError, losing the useful HTTP status and the library's normal response-carrying exception interface.

The response contract is documented here: https://developer.vuforia.com/library/vuforia-engine/web-api/vuforia-query-web-api/#response-message

Reproducer

Using a custom transport that returns this response:

from vws.response import Response

response = Response(
    text="",
    url="https://cloudreco.vuforia.com/v1/query",
    status_code=400,
    headers={},
    request_body=b"",
    tell_position=0,
    content=b"",
)

both of these paths fail at json.loads(response.text):

CloudRecoService(..., transport=transport).query(image=image)
await AsyncCloudRecoService(..., transport=async_transport).query(image=image)

Actual result:

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Expected behavior

Non-JSON 4xx responses should raise a stable library exception that retains the complete Response (including status, headers, and body). JSON parsing should only happen when the body is known to be JSON. Tests should cover empty and arbitrary-text 4xx responses for both clients.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    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