Skip to content

Google: name the account a configuration is set up for when it's another - #117

Open
odgrim wants to merge 4 commits into
track-a/google-missing-active-configfrom
track-a/google-another-account
Open

odgrim wants to merge 4 commits into
track-a/google-missing-active-configfrom
track-a/google-another-account

Conversation

@odgrim

@odgrim odgrim commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Change

The gcloud method's configuration choices name a configuration set up for another account than the Application Default Credentials sign in as, before the person picks it:

  • other (another account: "ana@example.com")
  • other (active, another account: "ana@example.com") when it is the active one.

Picking it is still refused at sign-in, naming both accounts, as before. A configuration with no account, or set up for the same account (case ignored), reads as before.

Decisions

  • configure asks Google who the login is, only when a configuration names an account: it refreshes the Application Default Credentials and asks tokeninfo (STS introspection for a workforce login), within one 5 s bound over both calls. Past the bound, or on any failure, no choice is marked and the error kind (timedOut, network, ...) goes to standard error. Only a user's or a workforce login is asked; a service account or other credential costs nothing, as at sign-in, which compares only those.
  • 5 s is a judgment, not a measurement: room for one refresh and one tokeninfo call on a slow link, without the form waiting long when the network is down.
  • A label shows at most 64 escaped characters of the account, so 999 configurations with 248-byte names and accounts of 4-byte characters fit in one 1 MiB line. With 256 they don't. A sign-in refusal still quotes 256. quoted takes the cap.
  • The ADC file's account is not read. gcloud 578.0.0 writes it empty: creds.WithAccount has no caller, and google-auth's Credentials.to_json writes _account, which defaults to "". So tokeninfo is the only source.
  • One comparison (session::another_account) serves the label and the refusal, and UserClaim picks what names the login (email or workforce subject) for both.
  • all_configuration_names returns ConfigurationNames, so a listed name is not parsed twice.
  • Google's crate gains a log to standard error, as Azure's has.
  • .cargo/mutants.toml excludes replace log with (), approved by the operator: a log line reaches only standard error, and tests never assert on log output. It drops exactly two mutants, Google's and Azure's log (cargo mutants --list over the workspace: 1635 without it, 1633 with it).

Gaps

  • fa7877a alone fails CI's mutation test (the log mutant); 9281c19 adds the exclusion.
  • configure with a user login and a configuration that names an account costs one refresh and one tokeninfo call, up to 5 s, and a sign-in that follows asks again. Two workforce tests now expect each pair twice.
  • The reason a label is missing reaches only standard error, which the app shows only when the plugin stops.
  • A configuration whose file can't be read is not marked, and the error is logged; signing in with it reports it.
  • AWS, Azure and Google each keep their own log; a shared one is not made here.
  • Not run against real Google.

Evidence

  • a_configuration_set_up_for_another_account_names_it failed before the change: left: ... "other (active)" ... right: ... "other (active, another account: \"ana@example.com\")". It now also checks an escaped and cut account, a refused refresh, a stalled refresh and a stalled tokeninfo call (each unmarked, at exactly 0 s or 5 s of paused time), and that no token is requested when no configuration names an account.
  • the_most_configurations_set_up_for_other_accounts_fit_in_a_line failed with the account cut at 256.
  • a_refusal_shows_each_account_escaped_and_bounded pins the refusal's 256-character cut of the account; with the label's 64 there, it fails (154 passed, 1 failed).
  • Hand mutants at 51a5a73, each caught (155 tests):
    • wait 1 s, wait 9 s, the bound on tokeninfo only, a failure marking every account, always asking Google: a_configuration_set_up_for_another_account_names_it fails (154 passed, 1 failed);
    • the label unescaped, the label cut at 256: that test and the fit test fail (153 passed, 2 failed).
  • Hand mutants at fa7877a, each caught: no wait bound, every account another, the active note dropped beside the account, the account unquoted (1 fails); a case-sensitive comparison (2 fail, both sign-in refusal tests); a user login named by its subject (18 fail); a service account compared (2 fail, including only_a_login_is_held_to_its_configurations_account).
  • CI's mutation test at 9281c19: 32 mutants tested in 7m: 27 caught, 5 unviable. Audit dependencies is red, as on main, until the pin-project-lite 0.2.19 lock update.
  • mise run check at 51a5a73: 507 tests run: 507 passed, 0 skipped, lint clean.
  • Rebased for the stack, 51a5a73 to 764faf6: the PR's diff has the same git patch-id --stable (c862a33d2c2f) and the same changed lines; 764faf6's tree equals git merge-tree --write-tree 51a5a73 origin/main. mise run check there: 509 tests run: 509 passed, 0 skipped.
  • gcloud 578.0.0: lib/googlecloudsdk/core/credentials/creds.py:243-260 (WithAccount, no caller in the SDK), 1731-1747 (a user's ADC is credentials.to_json minus the token fields); lib/third_party/google/oauth2/credentials.py:164 sets self._account = account or "" and :567 writes "account": self._account.

A log line reaches only standard error, and tests never assert on log
output, so no test can catch it.
configure no longer refreshes the ADC login when no configuration could be marked. A label shows at most 64 characters of the account, so 999 configurations with the longest names still fit in one line. A failure logs only its error kind. Tests cover a refused refresh, a stalled refresh, the exact 5 s wait and an account that needs escaping.
@odgrim
odgrim force-pushed the track-a/google-another-account branch from 51a5a73 to 764faf6 Compare December 6, 2026 16:05
@odgrim
odgrim added this pull request to stack #119 December 6, 2026 16:05
The refusal test checked only the account's first characters, so cutting it at the label's 64 passed.
@odgrim
odgrim marked this pull request as ready for review December 6, 2026 16:14

This branch has not been deployed

No deployments
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