Repository navigation
fix(no-ticket): show API errors whose field errors contain objects - #548
Draft
cloudsmith-iduffy wants to merge 1 commit into
Draft
cloudsmith-iduffy wants to merge 1 commit into
cloudsmith-iduffy wants to merge 1 commit into
Conversation
The error renderer joined field errors as strings. An API error with objects in its fields, such as DRF non_field_errors codes or nested serializer errors, stopped the CLI with a TypeError and hid the API error. Render each JSON error value as readable text in one helper. Lists of strings render as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused rendering changes address the reported crashes, include regression coverage, and have no identified blocking issues.
No open issues 🎉
What changed in this PR
Fixes CLI crashes when API field errors contain objects or nested values, complementing #526’s handling of non-object error bodies.
Changes:
- Adds recursive text rendering for nested error values while preserving structured JSON field output.
- Adds regression tests for nested fields, object details, and non-object fields.
- Documents the fix in the changelog.
| File | Description |
|---|---|
cloudsmith_cli/cli/tests/test_exceptions.py |
Adds text and JSON error-rendering regression tests. |
cloudsmith_cli/cli/exceptions.py |
Renders nested error values and normalizes non-object fields. |
CHANGELOG.md |
Documents the field-error rendering fix. |
Review effort: Balanced
This branch has not been deployed
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.
Description
When an API error has objects in its
fields, the CLI crashes and hides the real error. This happens with DRF error codes such as{"non_field_errors": [{"code": 1}]}and with nested serializer errors such as{"items": [{"name": ["required"]}]}. The renderer joined the values as strings, so it raisedTypeError.This PR adds one small helper in
cli/exceptions.pythat renders any JSON value as text. Strings stay as they are. Lists are joined with spaces, as before. Objects becomekey: messagepairs. Bothget_detailsandprint_error_detailsuse it. Afieldsvalue that is not an object is treated as non-field errors.Before, with
{"detail": "bad", "fields": {"non_field_errors": [{"code": 1}]}}:After:
Before, with
{"detail": "bad", "fields": {"items": [{"name": ["required"], "price": ["invalid"]}]}}, the text output printedDetail: badand then the sameTypeError. After:Type of Change
Additional Notes
fieldsobject is unchanged. Nested field errors keep their structure there. Only the text output and the JSONdetailstring use the new rendering.test_exceptions.py.core/api/exceptions.py. This PR changes onlycli/exceptions.py, so the two do not conflict.🤖 Generated with Claude Code