Skip to content

Expect a repeated service account create to be refused with CONFLICT - #37

Merged
mrcrgl merged 1 commit into
mainfrom
replayed-service-account-create
Nov 3, 2026
Merged

mrcrgl merged 1 commit into
mainfrom
replayed-service-account-create

Conversation

@mrcrgl

@mrcrgl mrcrgl commented Nov 3, 2026

Copy link
Copy Markdown
Member

The API changed how it answers a CreateServiceAccount repeated with a request id it already holds. It used to answer with the account, without its client secret. It now refuses with HTTP 409, FAILED_PRECONDITION, reason CONFLICT. The message names the account and says to delete it and create a new one, and the ErrorInfo metadata carries the name under serviceAccount.

Changes

a_service_account_s_client_secret_comes_with_a_notice now runs origin iam create-service-account … --request-id r-1 twice. The first run still checks the secret notice. For the second run, the fake answers with the API's 409 body, and the test checks that:

  • the command exits 1 with the failure envelope;
  • the description carries CONFLICT, organizations/o/serviceAccounts/sa-1, what to do and the request id;
  • standard error says nothing about a secret;
  • the repeat was sent once (a 409 isn't retried), with the same request id as the create.

The CLI code doesn't change. Its failure description is the SDK error's text, and that text already names the account.

Follow-up, not in this PR

api_error in crates/cli/src/sdk/runtime.rs appends each field violation to the description. Once the pinned sdk-rust exposes ApiError::metadata, it could append the ErrorInfo metadata the same way, as serviceAccount: organizations/…, when the message doesn't already contain it. That would need an sdk-rust bump, so it is kept out of this PR.

Testing

I ran every step in ci.yml locally: scripts/generate.sh --check, cargo fmt --check, clippy with and without --all-features, cargo test --locked --workspace, cargo test -p origincloud-cli --all-features, shellcheck and release/*.test.sh.

The API no longer answers a create repeated with the same request id with
the account minus its secret: the secret went out with the first answer
only, so it refuses the repeat with 409 CONFLICT and names the account to
delete. The test now repeats the create with the same --request-id and
checks the failure carries the reason, the account's name, what to do and
the request id, says nothing about a secret, and was sent once.
@mrcrgl
mrcrgl merged commit 8d36aaa into main Nov 3, 2026
6 checks passed
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.

1 participant