Skip to content

fix(upload): detect SSO interstitials titled with the org display name - #55

Merged
drogers0 merged 2 commits into
mainfrom
fix/issue-52-sso-display-name-title
Aug 17, 2026
Merged

fix(upload): detect SSO interstitials titled with the org display name#55
drogers0 merged 2 commits into
mainfrom
fix/issue-52-sso-display-name-title

Conversation

@drogers0

Copy link
Copy Markdown
Owner

Fixes #52.

Problem

When an organization's display name differs from its slug, its SAML SSO interstitial is titled with the display name (<title>Sign in to Acme Holdings, Inc</title> for slug acme-inc) and the page carries no /orgs/<slug>/sso link. Neither existing detector fires:

  • isSignInInterstitial requires the exact title Sign in to GitHub
  • isSAMLProtected builds both of its patterns from the slug, which the display-name title never contains

The lookup falls through to the generic "you may not have upload access" error — misleading for a user who has admin on the repo, and easy to "disprove" with gh api repos/<org>/<repo> --jq .permissions, which buries the correct SSO hint in the parentheses.

Fix

Add isAuthInterstitial as a fallback checked after the two specific detectors: a title matching Sign in to <anything> combined with a missing "currentUser" marker identifies any auth interstitial. This cannot fire on a real repo page — those always embed currentUser in the JS payload (as null when unauthenticated) and their titles start GitHub - <owner>/<repo>.

A stale session and an unauthorized SSO org are indistinguishable at this point (the caller only knows the slug, never the display name), so the new error names both causes and their fixes: re-extract the session token, or authorize at /orgs/<owner>/sso.

Branch order is unchanged for pages the specific detectors already handle, so the precise stale-session and slug-matched SSO messages still win when they apply.

Testing

  • New TestIsAuthInterstitial covering the display-name title from the issue, GitHub's own sign-in page, both repo-page variants, a repo whose description mentions signing in, and the degenerate bare Sign in to title
  • New TestGetUploadToken case asserting the issue Wrong error message when an organization uses SAML SSO #52 page yields the dual-cause message and not the access error
  • gofmt, go vet, go test ./... all pass

When an org's display name differs from its slug, the SAML SSO
interstitial's title shows the display name ("Sign in to Acme
Holdings, Inc" for slug acme-inc) and the page carries no
/orgs/<slug>/sso link, so neither isSignInInterstitial nor the
slug-based isSAMLProtected recognized it and users with full repo
access were told they may lack upload permission.

Add isAuthInterstitial as a fallback after both specific checks: any
"Sign in to ..." title combined with a missing "currentUser" marker
is an auth interstitial (a real repo page always embeds currentUser
and its title starts "GitHub - owner/repo"). Since a stale session
and an unauthorized SSO org are indistinguishable here, the error
names both causes with their fixes.

Fixes #52
Sign-in and SSO interstitials now surface their own error messages
before the generic one, so this symptom usually indicates a genuine
access problem rather than an expired session.
@drogers0
drogers0 merged commit a1340a5 into main Aug 17, 2026
2 checks passed
@drogers0
drogers0 deleted the fix/issue-52-sso-display-name-title branch August 17, 2026 22:25
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.

Wrong error message when an organization uses SAML SSO

1 participant