Title: fix(consent): stop asking for consent from a policy we failed to fetch by waleedlatif1 · Pull Request #7766 · simstudioai/sim · GitHub
Open Graph Title: fix(consent): stop asking for consent from a policy we failed to fetch by waleedlatif1 · Pull Request #7766 · simstudioai/sim
X Title: fix(consent): stop asking for consent from a policy we failed to fetch by waleedlatif1 · Pull Request #7766 · simstudioai/sim
Description: Summary
Emir reported the cookie banner coming back "every 1/15 times" on login, for an account that had already answered it. It isn't the banner updating — it's a failure mode, and each occurrence silently destroys his recorded consent.
What happens
The policy lookup is a cross-origin GET /init to the consent instance. That origin intermittently answers a bot challenge instead of the policy:
HTTP/2 403
x-vercel-mitigated: challenge
content-type: text/html ← Vercel Security Checkpoint page
A browser fetch() can't solve a JS challenge, so it just gets the 403. The runtime then logs API request failed, falling back to offline mode for consent banner and substitutes policyDefaults.offlineOptInBanner() — a generic opt-in policy — and carries on as if the lookup had succeeded.
Consent records the fingerprint of the policy it was given under. The substituted policy never matches, so updateStore treats it as a material policy change and does this:
if (storedPolicyFingerprint && storedPolicyFingerprint !== currentPolicyFingerprint) {
deleteConsentFromStorage(...)
set({ consents: resetConsents, consentInfo: null })
}
Stored consent is deleted, and with an opt-in policy and no record the banner returns — asking a question the visitor's jurisdiction may not even require.
Reproduced against production:
after consent -> banner gone : true c15t cookie : present
after one challenged /init -> banner back : true c15t cookie : DELETED
console: "API request failed, falling back to offline mode for consent banner"
The challenge is sticky per IP for ~3 minutes, which is why it reads as occasional bursts rather than every load.
The fix here
The banner renders only when the policy was actually resolved (initDataSource !== 'offline-fallback'). A load that fell back asks nothing; the next load that reaches the real policy asks if it still needs to.
Why not the documented same-origin proxy
c15t documents a /api/c15t/:path* rewrite, which would also dodge the challenge. It would break geo detection for us, so I did not use it — and recorded why next to the constant so it isn't "optimized" in later.
The instance resolves jurisdiction from the address the request arrives from. Measured against the live instance, every forwarding header we could send is ignored:
Header sent
Resolved
(baseline)
CCPA / US-CA
x-forwarded-for:
Open Graph Description: Summary Emir reported the cookie banner coming back "every 1/15 times" on login, for an account that had already answered it. It isn't the banner updating — it's a failure mode, a...
X Description: Summary Emir reported the cookie banner coming back "every 1/15 times" on login, for an account that had already answered it. It isn't the banner updating — it's a...
Opengraph URL: https://github.com/simstudioai/sim/pull/7766
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:0df606af-8618-c04e-eec9-9e6fe00f0d7f |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9832:2A369:2E231C:42597A:6AFB3742 |
| html-safe-nonce | b489672d8cd6ef1e7fa7f5b3e973f978f8f292f4582b367f4747ea91babbb48f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5ODMyOjJBMzY5OjJFMjMxQzo0MjU5N0E6NkFGQjM3NDIiLCJ2aXNpdG9yX2lkIjoiMTMzMTYxMjY2NjI0MjgwMzg2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2de940ab17de7672df66a4e017de624b15edd370148c07cb73c81d9797add21b |
| hovercard-subject-tag | pull_request:4508381769 |
| 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/simstudioai/sim/pull/7766/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary Emir reported the cookie banner coming back "every 1/15 times" on login, for an account that had already answered it. It isn't the banner updating — it's a failure mode, a... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2169b0dfbef67ed6b128074a5ed45bb7d5d1859783b10178b09a7765ad5f3693 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| 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 | 3b4fc8df5ef1c6757e733a23e6b81b6725021823 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width