Skip to content

fix: normalize host in resolveHost to prevent token lookup mismatch - #72

Merged
steve-calvert-glean merged 1 commit into
mainfrom
scalvert/fix-short-form-host-normalization
Apr 3, 2026
Merged

fix: normalize host in resolveHost to prevent token lookup mismatch#72
steve-calvert-glean merged 1 commit into
mainfrom
scalvert/fix-short-form-host-normalization

Conversation

@steve-calvert-glean

Copy link
Copy Markdown
Collaborator

Summary

  • Normalizes the host returned by resolveHost so that short-form GLEAN_HOST values (e.g. acme) don't cause a hash mismatch between token storage and token lookup

Problem

When GLEAN_HOST=acme (short form):

  1. resolveHost returns "acme" (raw from env)
  2. persistLoginStateSaveHostToFile("acme") normalizes to "acme-be.glean.com" in config
  3. SaveTokens("acme", tok) hashes un-normalized "acme"
  4. Next session: LoadConfig returns "acme-be.glean.com", LoadTokens uses a different hash → tokens not found

Fix

One-line change: resolveHost now returns config.NormalizeHost(cfg.GleanHost) instead of cfg.GleanHost, ensuring all downstream callers use the same normalized value.

Test plan

  • go test ./internal/auth/... — 23 tests pass (including new TestShortFormHostNormalizesConsistently)
  • go test ./... — 354 tests pass
  • golangci-lint run — no issues

🤖 Generated with Claude Code

When GLEAN_HOST is set to a short form (e.g. "acme" instead of
"acme-be.glean.com"), persistLoginState normalizes it in the config
file via SaveHostToFile, but SaveTokens hashes the un-normalized
value. On the next session, LoadConfig returns the normalized host
from the config file, but LoadTokens looks under a different hash
directory — tokens not found.

Fix by normalizing the host in resolveHost before returning it, so
all downstream callers (token storage, config persistence) use the
same consistent value.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@steve-calvert-glean steve-calvert-glean added the bug Something isn't working label Apr 3, 2026
@steve-calvert-glean
steve-calvert-glean merged commit 3f58c22 into main Apr 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants