Repository navigation
fix(propertydata): property data audit fixes (SDK-160) - #780
Conversation
- update_property_on_inventory no longer raises UnboundLocalError when the item has no value for the column; the value is added via the create path, as the docstring promises (PATCH add requires an existing PTD id). - TaskPropertyCreate sends visibleTrialNo as a number, matching the API schema, instead of the string "1". - PropertyData response model keeps valueNumeric/valueString instead of dropping them as undeclared extras. - Drop the dead history query param (the server derives history from the request body) and deprecate the no-op data_template_id parameter on void_interval_data/unvoid_interval_data, which the server ignores. - add_properties_to_task pairs POST response items to request properties by interval/column/trial identity instead of position, so mixed batches no longer misalign and rejected values no longer look registered.
|
Looks good - no bugs or correctness issues found. |
prasad-albert
left a comment
There was a problem hiding this comment.
LGTM! Verified backend contract parity, backward compatibility, caller ergonomics, and SDK conventions. Ready to merge.
# Conflicts: # tests/unit/test_api_response_field_coverage.py
|
Looks good - no bugs or correctness issues found. |
# Conflicts: # tests/unit/test_api_response_field_coverage.py
Code ReviewIssues Found
Summary1 issue found. Not a crash (failed pairs degrade gracefully to no DataTemplate), but if the response field types/presence do not exactly match the request-model types, the core fix silently misaligns and DataTemplate attachment is lost. Worth verifying the actual POST response shape (type of |
|
Looks good - no bugs or correctness issues found. |
|
Code Review Issues Found
Summary |
CircleCI Integration Tests failedBranch: |
CircleCI Integration Tests failedBranch: |
|
Both failures are substance metadata PATCHes failing with 400 'CAS API request failed (no response received)' - the staging CAS service was unreachable during the run. Environmental, unrelated to the property_data diff. Rerun once CAS recovers. |
CircleCI Integration Tests failedBranch: |
What
Fixes the five SMALL SDK findings from the backend API audit section 5.6 (propertydata):
update_property_on_inventoryUnboundLocalError:existing_idwas only assigned inside the match loop, so an item with no value for the column crashed instead of adding the value as the docstring promises. The variable is now initialized and, when no property-data record exists for the column, the value is added via the create path (PATCHaddrequires an existing PTD id; verified against api-propertydatapatchPropertyData.js).visibleTrialNotype:TaskPropertyCreatedefaultedvisible_trial_numberto the string"1"in an after-validator, so it serialized as a string. The API schema types it asnumber(docs/fields.yamlVisibleTrialNo). Now defaults to int1.PropertyDatadroppedvalueNumeric/valueString(extra="ignore"). The GET handler (getPropertyDataV2.js) returns them insideDataColumns[].PropertyData; both fields are now declared on the model.historyquery param fromadd_properties_to_task(bulkTrial.jsderives history from the request body and never reads the query param), and deprecated the no-opdata_template_idonvoid_interval_data/unvoid_interval_data(voidUnvoidPTDnever reads it), matching the in-file deprecation pattern used forreturn_fields/return_facets.add_properties_to_taskzipped request properties to the POST response by position, but the API returns existing trials before new trials and drops rejected values, so mixed batches misaligned and failed values looked registered. Response items are now paired back to request properties by (interval, data column, column sequence, visible trial number).Why
SDK-160. Each finding causes silent data corruption or a hard crash on documented call patterns.
How
Minimal diffs confined to
collections/property_data.pyandresources/property_data.py; contracts verified against the api-propertydata handlers (cloned for reference). Not changed (out of ticket scope): the MEDIUM items (PATCH 206 partial failures swallowed, single-interval client guard, search-item strictness), the [API]-side findings, andTrial.visible_trial_numberdefaulting to 1 when the task GET omitsvisibleTrialNo.Testing
No integration credentials available locally, so:
ruff format+ruff check --fix: clean (386 files unchanged, all checks passed)pytest tests/collections/test_property_data.py --collect-only -q: 14 collected (incl. newtest_update_property_on_inventory_adds_then_updates)pytest tests/core tests/utils tests/unit -q: 116 passed (incl. 2 new field-coverage tests pinningvalueNumeric/valueStringonPropertyDataand numericvisibleTrialNoserialization)visibleTrialNowire type and the key-based pairing against a shuffled responseIntegration tests added but not run live:
test_update_property_on_inventory_adds_then_updates(grouptasks, writes only to a data column unused by other tests in the file).Cake session: https://agents.ai.albertinventdev.com/sessions/910a4725-9404-4336-81dd-e30bfef0ce73