Title: fix(#210): replayed or cookie-less OAuth callbacks redirect home instead of 500 by sspickle · Pull Request #211 · vpython/glowscript · GitHub
Open Graph Title: fix(#210): replayed or cookie-less OAuth callbacks redirect home instead of 500 by sspickle · Pull Request #211 · vpython/glowscript
X Title: fix(#210): replayed or cookie-less OAuth callbacks redirect home instead of 500 by sspickle · Pull Request #211 · vpython/glowscript
Description: Fixes #210. What /google/auth catches OAuthError (the base of MismatchingStateError, also covering a replayed code's invalid_grant) and redirects to / — the only place a user whose callback can never succeed can actually do something useful. The no-state branch ("Yikes!") now redirects too instead of falling through to a guaranteed crash. Why redirect rather than an error page The state is single-use by design (CSRF protection — untouched here). Once it's consumed or the cookie never existed, retrying the same URL cannot work; the only recovery is starting a fresh sign-in from the landing page. A bare 500 invites exactly the wrong response — refresh — which is how one classroom machine produced 68 consecutive failures on 2026-09-01. Testing tests/test_auth_callback.py reproduces the exact production exception (RED on master: MismatchingStateError: mismatching_state: CSRF Warning!) and pins the redirect for both the replay shape and the bare-URL shape. Suite run under python:3.12 (matching the GAE runtime, since a 3.13 venv can no longer import the app — cgi was removed): 21 passed, 2 failed — both failures pre-exist on master in test_plotusers and are unrelated (verified by running master in the same container). Production data Steady 1–2% of sign-ins have failed this way for as far back as retention reaches, across a July-15 deploy boundary and a 6× traffic change — full numbers in #210. Update 2026-09-06: a third failure population, reported by a user Bruce forwarded two Error Reporting alerts from the production glowscript project. They are one event: http.client.RemoteDisconnected and urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected(...)) — the second is requests wrapping the first, and Error Reporting groups by stack signature. The live request hung 13.2s before the far end dropped it. That failure escaped the fix above. When the outbound token exchange to Google fails at the network level, requests raises RequestException, which is not an authlib OAuthError — so it propagated and rendered the same bare 500 this PR was written to remove. 1ebdc67 catches it, immediately before the OAuthError handler. Same reasoning applies unchanged: the single-use state is spent whether or not the exchange completed, so retrying that URL can never succeed. Current production breakdown 24 hours of glowscript request logs, every 5xx on /google/auth: cause count covered by MismatchingStateError (subclasses OAuthError) 5 f991582 OAuthError — user clicked Cancel on the consent screen 3 f991582 RequestException / RemoteDisconnected 2 1ebdc67 All ten now redirect instead of 500ing. /google/auth 500s go back to at least 2026-08-25. Testing Third case added to tests/test_auth_callback.py; all 3 pass. Mutation-checked, both directions: removing the RequestException handler fails the network test; removing the OAuthError handler fails the replay test. Each is independently necessary, so neither passes vacuously. Rest of the suite unchanged — 22 passed, with test_plotusers's 2 failures and test_e2e.py's missing playwright both confirmed pre-existing on master by stashing this branch. One more repo note pytest-mock is missing from requirements.txt even though conftest.py requires the mocker fixture. Without it these tests error at setup rather than fail, which reads like a broken test rather than an absent dependency. Not fixed here.
Open Graph Description: Fixes #210. What /google/auth catches OAuthError (the base of MismatchingStateError, also covering a replayed code's invalid_grant) and redirects to / — the only place a user whose callback can...
X Description: Fixes #210. What /google/auth catches OAuthError (the base of MismatchingStateError, also covering a replayed code's invalid_grant) and redirects to / — the only place a user whose callback...
Opengraph URL: https://github.com/vpython/glowscript/pull/211
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:aaac0ec7-1f8e-b90c-cb75-52a6780316da |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B108:22D266:44FB7:60B30:6B007E36 |
| html-safe-nonce | a048d027570d816e21c92fcdcb19826e717e26c5312f9a6c24bb06ea8406d7e2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMTA4OjIyRDI2Njo0NEZCNzo2MEIzMDo2QjAwN0UzNiIsInZpc2l0b3JfaWQiOiI4NTQ4MDg0NTMxMjQ3MjE4MjMwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1489d75eca20701809b17c9e9dc3088d7cffba0458bf856effc1b4666b935aff |
| hovercard-subject-tag | pull_request:4413966787 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/vpython/glowscript/pull/211/files |
| twitter:image | https://avatars.githubusercontent.com/u/1708412?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1708412?s=400&v=4 |
| og:image:alt | Fixes #210. What /google/auth catches OAuthError (the base of MismatchingStateError, also covering a replayed code's invalid_grant) and redirects to / — the only place a user whose callback can... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 82c186f13e104004ab7bdb779f3195e59dd38bfde531aaa74b76470fc2462b83 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/vpython/glowscript git https://github.com/vpython/glowscript.git |
| octolytics-dimension-user_id | 1280757 |
| octolytics-dimension-user_login | vpython |
| octolytics-dimension-repository_id | 187905631 |
| octolytics-dimension-repository_nwo | vpython/glowscript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 187905631 |
| octolytics-dimension-repository_network_root_nwo | vpython/glowscript |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d1bc2aa1939001689f5ce935982c10a6138f745c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width