feat(client): surface structured shape errors on TangoValidationError#46
Merged
Conversation
400 messages now name the rejected field(s) and reason when the API returns structured issues, and TangoValidationError gains .issues and .available_fields accessors over response_data. Closes #45 (client half; server half tracked in makegov/tango#2586). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What
Addresses the client half of #45: when the API returns a structured 400 (shape errors return
{"error": ..., "issues": [{"path", "reason"}], "available_fields": {...}}), the exception message previously surfaced only the top-levelerrorstring, and the structured details were reachable only by digging throughresponse_data.Invalid request parameters: Invalid shape: tradeoff_process (unknown_field)instead ofInvalid request parameters: Invalid shape.TangoValidationError.issues(list of issue dicts,[]when absent) andTangoValidationError.available_fields(dict orNone), mirroring howTangoRateLimitErrorexposes.wait_in_seconds/.detailoverresponse_data.Why
Shape errors are currently not self-diagnosable from the exception — callers bisect their shape string by hand (reported in #45). The server already sends everything needed; the client just didn't show it.
Testing
.issues,.available_fields,response_dataintact) and plain-body case (accessors return empty defaults).uv run pytest -m "not integration": 332 passed; the one failure (tests/production/test_production_smoke.py::test_search_filters) pre-exists on main and is unrelated (live-API smoke test).ruff checkand strictmypyclean on changed files (remaining ruff findings intests/integration//test_shapes.pypre-exist on main).Risks
None expected — purely additive; message text changes but message strings aren't part of the surface contract.
response_databehavior unchanged.Notes
Server half of #45 (bare object fields 400ing as
unknown_field) is tracked upstream in makegov/tango#2586.Closes #45
🤖 Generated with Claude Code