Skip to content

Fix wrong raw output during vastai attach ssh --raw cmd call#255

Merged
vastzuby merged 2 commits intovast-ai:masterfrom
borisermakof:fix_attach_ssh_key_raw_output_and_description
Feb 20, 2026
Merged

Fix wrong raw output during vastai attach ssh --raw cmd call#255
vastzuby merged 2 commits intovast-ai:masterfrom
borisermakof:fix_attach_ssh_key_raw_output_and_description

Conversation

@borisermakof
Copy link
Contributor

@borisermakof borisermakof commented Aug 8, 2025

Hey folks!

This PR fixes two issues:

  • Incorrect attach ssh command description.
  • Missing proper JSON output when the --raw parameter is used.

While working with the vastai CLI, I noticed that my code could not parse JSON when running:

vastai attach ssh <params> --raw

This is because the command returned plain text, which is not useful for programmatic parsing.

Example before the fix:

❯ python vast.py attach ssh <id> <path>/keys/vastai_key.pub --raw  

"{'success': True, 'msg': 'SSH key added to instance.', 'key': '{"id": <id>, "user_id": null, "default": null, "public_key": "<keydata>", "private_key": null, "created_at": <date>, "deleted_at": null}'}  
null

The output is a string containing a plain text, not valid JSON.
There’s also an extra null line at the end. This forces me to do additional parsing/replacing before I can run json.loads(output).

Example after the fix:

❯ python vast.py attach ssh <id> <path>keys/vastai_key.pub --raw  

{
  "key": "{\"id\": <id>, \"user_id\": null, \"default\": null, \"public_key\": \"<key_data>\", \"private_key\": null, \"created_at\": 1754655150.416915, \"deleted_at\": null}",
  "msg": "SSH key added to instance.",
  "success": true
}

Now the output is valid JSON and can be directly passed to json.loads() without additional processing.

@borisermakof borisermakof changed the title Fix wrong raw output during vastai attach ssh key call Fix wrong raw output during vastai attach ssh --raw key call Aug 8, 2025
@borisermakof borisermakof changed the title Fix wrong raw output during vastai attach ssh --raw key call Fix wrong raw output during vastai attach ssh --raw cmd call Aug 8, 2025
Copy link
Contributor

@vastzuby vastzuby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks for contributing :)

@vastzuby vastzuby merged commit 0af8199 into vast-ai:master Feb 20, 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