Skip to content

feat(compute): improve error message when instance not found in zone#805

Open
natalie-o-perret wants to merge 1 commit intomasterfrom
natalieperret/sc-167368/exo-cli-minor-ux-improvement-exo-compute
Open

feat(compute): improve error message when instance not found in zone#805
natalie-o-perret wants to merge 1 commit intomasterfrom
natalieperret/sc-167368/exo-cli-minor-ux-improvement-exo-compute

Conversation

@natalie-o-perret
Copy link
Contributor

@natalie-o-perret natalie-o-perret commented Feb 26, 2026

Description

When exo compute instance <action> commands fail because the instance does not exist in the default zone, the error message previously surfaced a raw SDK message with no context:

"foo" not found in ListInstancesResponse: Not Found

This PR introduces a findInstance helper in cmd/compute/instance/instance_find.go that wraps FindListInstancesResponseInstances and enriches the not-found error with the zone that was searched and a hint to use -z:

instance "foo" not found in zone ch-gva-2
Hint: use -z <zone> to specify a different zone, or run 'exo compute instance list' to see instances across all zones

Changes:

  • Added findInstance helper in cmd/compute/instance/instance_find.go, wrapping FindListInstancesResponseInstances with zone-aware error enrichment.
  • Migrated all 24 call sites across the instance subcommands (show, reboot, start, stop, scale, update, reset, reset-password, reveal-password, resize-disk, scp, ssh, snapshot create, snapshot revert, security-group add/remove, private-network attach/detach/update-ip, elastic-ip attach/detach, enable-tpm, console-url, delete) to use the new helper.
  • Added tests/e2e/scenarios/with-api/compute/instance_not_found_error.txtar, an API-driven e2e scenario verifying the enriched error message on show, reboot and stop. Uses the testscript runner from tests/e2e: add API testscript runner and compute instance reboot scenario #804.

Checklist

(For exoscale contributors)

  • Changelog updated (under Unreleased block, and add the Pull Request #number for each bit you add to the CHANGELOG.md)
  • Testing

Testing

Covered by the e2e scenario above (requires API credentials, runs under -tags=api).

@natalie-o-perret natalie-o-perret force-pushed the natalieperret/sc-167368/exo-cli-minor-ux-improvement-exo-compute branch 2 times, most recently from 1353595 to 242469c Compare February 26, 2026 22:58
@natalie-o-perret natalie-o-perret changed the base branch from master to natalieperret/sc-167544/feature-request-cli-add-testscript February 26, 2026 22:58
@natalie-o-perret natalie-o-perret force-pushed the natalieperret/sc-167544/feature-request-cli-add-testscript branch from 40b598f to 9ca3d94 Compare February 27, 2026 08:47
@natalie-o-perret natalie-o-perret force-pushed the natalieperret/sc-167368/exo-cli-minor-ux-improvement-exo-compute branch from 242469c to dd783eb Compare February 27, 2026 08:48
Base automatically changed from natalieperret/sc-167544/feature-request-cli-add-testscript to master March 4, 2026 07:32
@natalie-o-perret natalie-o-perret force-pushed the natalieperret/sc-167368/exo-cli-minor-ux-improvement-exo-compute branch 2 times, most recently from 4caef3c to bfa2851 Compare March 4, 2026 08:22
…[sc-167368]

- Introduce findInstance helper wrapping FindListInstancesResponseInstances
  with a zone-aware error and -z hint when the instance is not found.
- Apply findInstance across all 24 instance subcommands that look up by name/ID.
- Add e2e txtar tests covering every affected command.
- Redirect go test stderr in e2e CI to suppress false Error banner in Actions UI.
@natalie-o-perret natalie-o-perret force-pushed the natalieperret/sc-167368/exo-cli-minor-ux-improvement-exo-compute branch from 026fc0d to 3961716 Compare March 4, 2026 09:29
@natalie-o-perret natalie-o-perret marked this pull request as ready for review March 4, 2026 10:29
@natalie-o-perret natalie-o-perret requested review from a team and nerzhul March 4, 2026 10:29
Copy link
Contributor

Choose a reason for hiding this comment

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

The file naming does not fit in our code organization (file name -> command name).
Put this function in the instance.go which is logically shared by all commands.

run: |
cd tests/e2e
go test -v -tags=api -timeout 30m -run TestScriptsAPI
go test -v -tags=api -timeout 30m -run TestScriptsAPI 2>&1
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is stderr redirection needed now? Put at least a note about it in the PR description so it ends up in the commit message when we merge.

Copy link
Contributor Author

@natalie-o-perret natalie-o-perret Mar 5, 2026

Choose a reason for hiding this comment

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

It's a tiny detail, GitHub Action that shows an error cause of the presence of a stderr (when looking at the details, the job isn't in error, though just when you're about to expand the job output / details)

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