Skip to content

Add from_response_dict classmethods to report classes#2882

Merged
adamtheturtle merged 3 commits intomainfrom
adamtheturtle/reports-from-response-dict
Feb 25, 2026
Merged

Add from_response_dict classmethods to report classes#2882
adamtheturtle merged 3 commits intomainfrom
adamtheturtle/reports-from-response-dict

Conversation

@adamtheturtle
Copy link
Member

@adamtheturtle adamtheturtle commented Feb 25, 2026

Centralize API response parsing logic into classmethods on DatabaseSummaryReport, TargetSummaryReport, TargetStatusAndRecord, and QueryResult.

This eliminates 73 lines of duplicated construction code across sync/async VWS and query clients. Each report class now encapsulates the logic for parsing its raw API response dict, including type conversions, nested object construction, and datetime handling.

Callers in vws.py, async_vws.py, query.py, and async_query.py are simplified to single-line method calls instead of multi-line manual construction.


Note

Low Risk
Primarily a refactor that centralizes and reuses existing response-parsing/type-coercion logic; risk is limited to potential subtle mismatches in field conversion (notably date/datetime handling) affecting report construction.

Overview
Centralizes Vuforia API response parsing by adding from_response_dict constructors to DatabaseSummaryReport, TargetSummaryReport, TargetStatusAndRecord, and QueryResult (including nested TargetData/timestamp conversion).

Sync/async clients (vws.py, async_vws.py, query.py, async_query.py) now delegate report construction to these helpers, removing duplicated inline parsing logic and related imports (e.g., datetime, date, TargetRecord/TargetData direct usage).

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

adamtheturtle and others added 3 commits February 25, 2026 08:46
Centralize API response parsing logic into classmethods on DatabaseSummaryReport, TargetSummaryReport, TargetStatusAndRecord, and QueryResult. This eliminates 75 lines of duplicated construction code across sync/async VWS and query clients.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

current_month_recos=int(response_dict["current_month_recos"]),
failed_images=int(response_dict["failed_images"]),
inactive_images=int(response_dict["inactive_images"]),
name=response_dict["name"],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DatabaseSummaryReport name field loses str() conversion

Medium Severity

The original DatabaseSummaryReport construction in vws.py and async_vws.py used name=str(object=response_data["name"]) so the name was always a string. The new from_response_dict passes response_dict["name"] directly, removing that defensive conversion. If the API returns a non-string (e.g., null or a number), this can trigger type errors or pass invalid data through.

Fix in Cursor Fix in Web

@adamtheturtle adamtheturtle merged commit d01ce65 into main Feb 25, 2026
16 checks passed
@adamtheturtle adamtheturtle deleted the adamtheturtle/reports-from-response-dict branch February 25, 2026 08:54
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