Add from_response_dict classmethods to report classes#2882
Merged
adamtheturtle merged 3 commits intomainfrom Feb 25, 2026
Merged
Add from_response_dict classmethods to report classes#2882adamtheturtle merged 3 commits intomainfrom
adamtheturtle merged 3 commits intomainfrom
Conversation
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>
There was a problem hiding this comment.
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"], |
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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_dictconstructors toDatabaseSummaryReport,TargetSummaryReport,TargetStatusAndRecord, andQueryResult(including nestedTargetData/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/TargetDatadirect usage).Written by Cursor Bugbot for commit c5e06a2. This will update automatically on new commits. Configure here.