fix: exit non-zero when setup aws fails to write the profile#349
Merged
gtsiolis merged 1 commit intoJul 1, 2026
Merged
Conversation
Writing the LocalStack AWS profile is the whole purpose of `lstk setup aws` (and the deprecated `lstk config profile`), but awsconfig.Setup emitted a warning and returned nil when the write itself failed — so a read-only ~/.aws, a permission error, or a full disk left the profile unwritten while the process still exited 0, masking the failure from users, CI, and agents. This is the same "prints an error yet exits 0" class as DEVX-941, in a real command. Thread an `explicit` flag through Setup: the user-invoked commands now emit a structured ErrorEvent and return a SilentError on a write failure (exit 1), while the best-effort post-start convenience path (EnsureProfile during `lstk start`) keeps warning and continuing so a profile-write hiccup never aborts an already-running emulator. Add an integration test that makes ~/.aws read-only, confirms the prompt, and asserts a non-zero exit (fails before this change, passes after).
e2880eb to
8662b29
Compare
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.
Closes DEVX-944.
lstk setup aws(and the deprecatedlstk config profile) reported success and exited 0 even when it failed to write the LocalStack AWS profile. Writing the profile is the command's whole purpose, butawsconfig.Setupemitted a warning and returnednilwhen the write itself failed (read-only~/.aws, permission denied, full disk, or a corrupt existing ini). The profile was never written, yet the process exited 0 — masking the failure from users, CI, and agents, so downstreamaws --profile localstackcalls then failed confusingly.Setupnow takes anexplicitflag:lstk setup aws,lstk config profile) emit a structuredErrorEventand return aSilentErroron a write failure → exit 1.EnsureProfileduringlstk start) keeps warning and continuing, so a profile-write hiccup never aborts an already-running emulator.Tests
test/integration/awsconfig_test.goadds a case that makes~/.awsread-only, confirms the prompt, and asserts a non-zero exit — it fails before this change and passes after. (Skipped under root, where directory permissions are bypassed.)Context
Split out of #346 (DEVX-941), which stays focused on invalid-usage exit codes. This is a sibling instance of the same "prints an error yet exits 0" class, in a different command.