spacectl
spacectl copied to clipboard
Can stack local-preview determine 40X errors?
When running local preview without a valid auth token:
$ spacectl stack local-preview
2024/02/26 15:53:14 no stack found: no --id flag was provided and stack could not be found by searching the current directory
The stack is not found because the token is invalid.
When passing an explicit id the message is more helpful and notes that I am unauthorized:
$ spacectl stack local-preview --id ansible-pmm
2024/02/26 15:53:36 failed to check if stack exists: failed to query GraphQL API when checking if a stack exists: unauthorized: you can re-login using `spacectl profile login`
I think it would be more helpful if we can determine the user is unauthorized when trying to discover the stack in the first incantation.
This is a bit strange, had a quick look at it and both of these paths use the same graphql client and parse the responses in the same way, but they react different to the unauthorised error. Might not be a very simple fix.