Skip to content

fix(cli): execute crashes with 'str' object has no attribute 'get'#422

Open
tengxiaoliu wants to merge 1 commit into
vast-ai:masterfrom
tengxiaoliu:fix/execute-str-attributeerror
Open

fix(cli): execute crashes with 'str' object has no attribute 'get'#422
tengxiaoliu wants to merge 1 commit into
vast-ai:masterfrom
tengxiaoliu:fix/execute-str-attributeerror

Conversation

@tengxiaoliu

@tengxiaoliu tengxiaoliu commented Jun 15, 2026

Copy link
Copy Markdown

Summary

vastai execute <id> <command> crashes on every successful invocation with:

AttributeError: 'str' object has no attribute 'get'

Root cause

vastai/api/instances.py::execute() already polls the result URL internally and returns the command output as a str on success (or the raw response dict on failure, when there is no result_url).

The CLI handler vastai/cli/commands/misc.py::execute() was never updated for this. It still assumes the old dict shape — calling rj.get("success") and re-polling rj["result_url"] / rj["writeable_path"]. On the success path rj is a str, so .get() raises immediately, and the polling loop below it is now dead code (the API layer already polled).

The sibling logs() handler in the same file already handles the str return correctly via isinstance(rj, str)execute() was simply missed in the refactor.

What it does

Removes the redundant dict-based polling in the CLI handler and prints what instances_api.execute() returns (str output on success, error dict otherwise). One file changed, −11 / +6.

Test plan

Verified against current master (before vs. after the change):

Command Before After
vastai execute <id> 'ls /workspace/...' crash prints listing
vastai execute <id> 'du -d1 -h /workspace/...' crash prints usage

The crash is in command-independent code (after the result is fetched), so it affects every successful execute, including rm.

instances_api.execute() polls the result URL internally and returns the
command output as a str on success (or the raw response dict on failure).
The CLI execute() handler still assumed the old dict shape and called
rj.get("success"), raising

    AttributeError: 'str' object has no attribute 'get'

on every successful 'vastai execute' invocation. The dict-based polling
loop here is now dead code (the API layer already polled), so just print
the returned value.
@vastzuby vastzuby self-assigned this Jun 15, 2026
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