Skip to content

fix(CLN-3684): print the API's reason for a refused cloud copy - #522

Merged
eliasthompson merged 1 commit into
masterfrom
feat/CLN-3684-cloud-copy-cli-errors
Oct 2, 2026
Merged

eliasthompson merged 1 commit into
masterfrom
feat/CLN-3684-cloud-copy-cli-errors

Conversation

@eliasthompson

Copy link
Copy Markdown
Contributor

Companion to vastai/vast PR #6069 (CLN-3684), which makes the cloud copy endpoint refuse with a named, structured 4xx instead of a 200 carrying success: false.

Why

cloud copy had two failure modes, and both hid what went wrong:

  • r.raise_for_status() turned any 4xx into a Python traceback, replacing a sentence written for the user with a stack dump.
  • The success branch keyed on r.status_code == 200, so a refusal carried in a 200 body printed "Cloud Copy Started" and exited 0. A copy that was rejected looked like a copy that had begun.

The second one survives the backend change on its own, which is why this is a fix rather than an adaptation.

What changes

exit_on_copy_refusal(response) checks both the status and the body, prints the API's msg to stderr, and exits non-zero. A copy only reports as started when the API actually accepted it.

Verified against four shapes: a named 400, the 409 guard refusal, a legacy 200 with success: false, and a 500 with no JSON body (falls back to the response text, then the status). All four print the message and exit 1; a real 200 success proceeds untouched.

Note for reviewers

This works against the current backend too. Today every refusal is a 200, so the success: false path is the one that fires; once #6069 ships, the 4xx path takes over. Either way the user gets a sentence and a non-zero exit, so there is no ordering constraint between the two merges.

🤖 Generated with Claude Code

…it non-zero

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@eliasthompson
eliasthompson merged commit 485c974 into master Oct 2, 2026
5 checks passed
@eliasthompson
eliasthompson deleted the feat/CLN-3684-cloud-copy-cli-errors branch October 2, 2026 21:46
@sammy-vastai

Copy link
Copy Markdown
Contributor

Hi Elias, #522 only changed vast.py, so the fix only reaches people who still download that file directly, and that file is deprecated. The installed vastai command runs from vastai.cli.main:main (pyproject.toml:55), and its cloud copy code is in vastai/cli/commands/storage.py and vastai/api/storage.py. #522 didn't change either file.

What the installed CLI does now:

  • 200 with success: false: prints "Cloud Copy Started" and exits 0 (storage.py:296 checks only if rj:).
  • 4xx: prints Failed with error 4xx: <msg> to stderr and exits 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants