fix(cli): execute crashes with 'str' object has no attribute 'get'#422
Open
tengxiaoliu wants to merge 1 commit into
Open
fix(cli): execute crashes with 'str' object has no attribute 'get'#422tengxiaoliu wants to merge 1 commit into
tengxiaoliu wants to merge 1 commit into
Conversation
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.
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.
Summary
vastai execute <id> <command>crashes on every successful invocation with: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 noresult_url).The CLI handler
vastai/cli/commands/misc.py::execute()was never updated for this. It still assumes the old dict shape — callingrj.get("success")and re-pollingrj["result_url"]/rj["writeable_path"]. On the success pathrjis astr, 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 viaisinstance(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):vastai execute <id> 'ls /workspace/...'vastai execute <id> 'du -d1 -h /workspace/...'The crash is in command-independent code (after the result is fetched), so it affects every successful
execute, includingrm.