AI Studio Preview: R2 Unauthorized — Request DEV Sandbox Restart העתק

Hello Google AI Studio team,

I need help with a persistent issue in the Build Preview environment of my application, Breslev Digital.

The problem:

  • The published production application works and displays 11 media lessons.

  • The AI Studio Preview fails to load the media library.

  • Preview logs show R2 SNAPSHOT READ FAILED Unauthorized.

  • Firestore also reports RESOURCE_EXHAUSTED because the free daily read quota was exceeded.

  • API requests to /api/media sometimes return HTML instead of JSON.

What we have already verified:

  • All five Cloudflare R2 environment variables in AI Studio Secrets match those in the working production Cloud Run revision.

  • The application builds successfully.

  • The R2 client is initialized once per Node.js process and caches its credentials.

  • Reloading the Preview page does not guarantee a backend process restart.

  • There is no explicit backend restart control in the AI Studio Preview interface.

Our request:

Could your team please restart or recreate the application’s DEV sandbox, ensuring that the latest configured Secrets are injected into the Node.js backend process?

Please also investigate whether this is an AI Studio Preview environment-variable injection or runtime issue.

Important: Please do not modify or redeploy the published production application, change our Secrets, or delete any stored data.

If you need our application ID or diagnostic details, please tell us how to provide them securely.

Thank you!

Hello @BreslevDigital,

Manual restarts of an app’s Build Preview environment are not available from this forum, and our records indicate that the Preview environment for Breslev Digital is now working fine.

If you still encounter RESOURCE_EXHAUSTED on Cloud Firestore, that error occurs when a project on the free tier reaches its daily document-read limit (Firestore quotas); enabling Cloud Billing on the linked Google Cloud project lifts the free daily cap.

Please let us know if you are still facing any issue.

The R2 Unauthorized error (or 401/403 when loading Preview resources) in the Google AI Studio build environment occurs when the temporary Dev Sandbox session token expires or becomes locked against the browser’s local Worker, even though the code itself is completely fine.

To reset the Dev Sandbox and restore the Preview display immediately without waiting for a manual timeout:

Clear the Service Worker and IndexedDB for the Preview only:
Open Developer Tools in your browser (F12 → Application tab → Storage), check Unregister service workers and IndexedDB, and click Clear site data for the Preview domain (*.scf.usercontent.goog / aistudio.google.com).
Restart the container via an environment variable change or duplication (Remix / Fork):
If the server-side Sandbox is stuck on an old process, click the app menu at the top and select Copy / Remix App (or make a small change to the package.json file and save). This provisions an entirely new Dev Sandbox instance with fresh R2 permissions.