Skip to content

fix(me): fall back to the Gmail profile when People returns no email - #173

Merged
piekstra merged 1 commit into
mainfrom
fix/me-email-fallback
Aug 12, 2026
Merged

fix(me): fall back to the Gmail profile when People returns no email#173
piekstra merged 1 commit into
mainfrom
fix/me-email-fallback

Conversation

@piekstra

Copy link
Copy Markdown
Contributor

Why

Identity output was inconsistent, and in the wrong direction: gro me (the canonical identity surface) printed a blank email —

people/c123 | Some Name | -

— while gro config test printed Authenticated as: <email>. gro me --id (the scripting surface) printed just -.

Root cause

people/me only returns the account's own email when the token carries an email-bearing scope. gro requests userinfo.profile but deliberately not userinfo.email, so People comes back email-less. The Gmail profile always knows the address (via the always-granted gmail.modify scope) — which is why config test had it.

What

When People's email is blank, resolve it from the Gmail profile (injected GmailEmailFactory seam, matching the existing ClientFactory pattern):

  • One extra API call, only when the email is missing.
  • Best-effort: a Gmail hiccup degrades to the old - rendering rather than failing me.
  • Fixes both the pipe one-liner and --id.

Considered and rejected: adding the userinfo.email scope. Any scope-set change trips the scope-drift gate and forces every existing user through a full re-auth — for data we can already read with granted scopes.

Tests

Fallback fills the one-liner and --id; fallback failure degrades gracefully; no Gmail call when People already supplied the email. make check green.

'gro me' printed the display name but a blank ('-') email, while 'config
test' printed 'Authenticated as: <email>' - inconsistent identity output,
with the canonical identity command being the less useful one.

Root cause: people/me only returns the account's own email when the token
carries an email-bearing scope. gro requests userinfo.profile but not
userinfo.email, so People comes back email-less; the Gmail profile always
knows the address under the always-granted gmail.modify scope.

Fall back to the Gmail profile when People's email is blank (one extra API
call, only in that case; best-effort - a fallback failure degrades to the
old '-' rendering rather than failing me). Covers the one-liner and --id.

Deliberately NOT fixed by adding the userinfo.email scope: a scope-set
change trips the scope-drift gate and forces every existing user through
re-auth, for data we can already read.

@piekstra-dev piekstra-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated PR Review

Reviewed commit: 3f3dc302c27c
Profile: reviewer - Posting as: piekstra-dev

Summary

Reviewer Findings
go:implementation-tests 0
policies:conventions 0

Reviewer Coverage

Reviewer Status Inspected Skipped Constraints
go:implementation-tests complete_broad internal/cmd/me/me.go, internal/cmd/me/me_test.go, internal/cmd/me/output.go unavailable Reviewed only the three assigned files; the external gmail.NewClient/GetProfile implementation in google-cli-common is out of scope and not inspected.
policies:conventions complete_broad internal/cmd/me/me.go, internal/cmd/me/output.go unavailable unavailable

0 PR discussion threads considered. 0 summarized; 0 resolved.


Completed in 2m 22s | $1.14 | claude-sonnet-5 | cr 0.10.268
Field Value
Model claude-sonnet-5
Reviewers go:implementation-tests, policies:conventions
Engine claude_cli · claude-sonnet-5
Reviewed by cr · piekstra-dev
Duration 2m 22s wall · 3m 18s compute
Cost $1.14
Tokens 74 in / 14.2k out

Per-workstream usage

Workstream Model In Out Cache read Cache create Cost Duration
orchestrator-selection claude-sonnet-5 6 1.4k 59.0k 12.8k $0.12 19s
go:implementation-tests claude-sonnet-5 22 4.9k 358.4k 28.6k $0.35 1m 07s
policies:conventions claude-sonnet-5 40 7.4k 759.9k 34.7k $0.55 1m 41s
orchestrator-rollup claude-sonnet-5 6 383 67.8k 15.2k $0.12 10s

@piekstra
piekstra merged commit 8369642 into main Aug 12, 2026
11 checks passed
@piekstra
piekstra deleted the fix/me-email-fallback branch August 12, 2026 18:27
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