Skip to content

fix(auth-bootstrap): stay up for a retry on wrong-account instead of exiting#892

Open
dmerrick wants to merge 1 commit into
developfrom
fix/auth-bootstrap-wrong-account-retry
Open

fix(auth-bootstrap): stay up for a retry on wrong-account instead of exiting#892
dmerrick wants to merge 1 commit into
developfrom
fix/auth-bootstrap-wrong-account-retry

Conversation

@dmerrick

Copy link
Copy Markdown
Collaborator

Summary

  • When the wrong Twitch account signs in, auth-bootstrap detects the mismatch (mytwitch.ErrIdentityMismatch) and writes no token — but it used to log.Fatalf, killing the job pod and dropping the kubectl port-forward, so the bootstrap chain moved on without a chance to fix it.
  • The wrong-account branch now keeps the HTTP listener (and the port-forward) up: it renders the "wrong account" page, re-surfaces the authorize URL so you can sign out / use incognito and re-auth in place, and does not signal completion.
  • Only a matching identity writes the token and exits 0. The wait loop stays bounded by the existing flowTimeout, so a never-corrected mismatch still terminates. Genuine non-recoverable errors still fail loudly.

Test plan

  • go vet ./cmd/auth-bootstrap/ and go build ./cmd/auth-bootstrap/ clean (via the macOS CGO task env)
  • task test:macos — all packages pass except a pre-existing pkg/server build failure on develop (undefined: renderProfile in profile_test.go), unrelated to this change
  • Wrong-account sign-in keeps the page up and re-offers the authorize URL; signing in as the correct identity then writes the token and exits 0

…exiting

When the wrong Twitch account signs in, GenerateUserAccessToken returns
ErrIdentityMismatch and no token is written — but the callback handler used
to signal the done channel, which fataled the process. That terminated the
job pod, dropped the kubectl port-forward, and let the bootstrap chain move
on without a chance to correct it.

Now the mismatch branch keeps the HTTP listener (and thus the port-forward)
up: it renders the "wrong account" page, re-surfaces the authorize URL so the
operator can sign out / use incognito and re-auth in place, and does NOT
signal done. Only a matching identity writes the token and exits 0. The wait
loop stays bounded by flowTimeout, so a never-corrected mismatch still
terminates. Genuine non-recoverable errors still fail loudly via done.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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