fix(eng-13978): JSON output for package sync failure with status reason - #368
Merged
BartoszBlizniak merged 2 commits intoAug 20, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a crash and improves machine-readable error reporting for cloudsmith push <format> when a package sync fails under -F json / pretty_json, ensuring the server-provided failure reason is preserved and emitted.
Changes:
- Preserve
status/stage/reasonfromget_package_status()in the JSON-mode polling path to avoidUnboundLocalErrorand to surface the sync failure reason. - Emit a JSON error envelope to stdout on sync failure in JSON output modes (while keeping human-readable failure text on stderr).
- Add a regression test covering JSON-mode sync failure output (stderr text + stdout envelope).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
cloudsmith_cli/cli/commands/push.py |
Fixes JSON-mode sync polling to keep failure fields and emits a JSON error envelope on sync failure. |
cloudsmith_cli/cli/tests/test_push.py |
Adds a regression test ensuring JSON-mode sync failures include the server reason and a parseable stdout envelope. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
BartoszBlizniak
marked this pull request as ready for review
August 20, 2026 12:04
cloudsmith-iduffy
approved these changes
Aug 20, 2026
BartoszBlizniak
deleted the
eng-13978-cloudsmith-cli-cloudsmith-push-crashes-with
branch
August 20, 2026 13:33
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
cloudsmith push <format>crashed withUnboundLocalError: cannot access local variable 'reason'instead of reporting why a sync failed. Only in-F json/pretty_jsonmode, whose polling loop discarded the status fields fromget_package_status. Now it keeps them, so failures print the stage and the server's reason like the progressbar path already did.JSON mode also left nothing on stdout when a sync failed, since the human-readable text goes to stderr. Failures now emit an error envelope on stdout, matching the shape
handle_api_exceptionsproduces for API failures.Also rewrites
AGENTS.md: the tooling sections still documented black/isort/flake8/pylint after the move to ruff.Type of Change
Additional Notes
Before - pushing a duplicate package with
-F json:After - parseable envelope on stdout, human-readable text on stderr, exit code 1:
metacarriesstatus/stage/secondsrather thancode/description, since a sync failure has no HTTP status.Not breaking:
prettyoutput untouched, success path still emits{"data": {...}}, and failures already exited 1 for anyone who did not hit the crash.To verify beyond CI, push the same package twice to a repo without "Replace Package w/ Same Version" enabled, with
-F json --sync-attempts 1. Tested locally against a scratch repo on a personal fork.