Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(x-content): read the Cloud Storage bundle bucket even when R2 credentials are absent

nirholasad4be8c16bfc
diff --git a/api/_lib/x-content/overlay.js b/api/_lib/x-content/overlay.js
index 848e6a20d..a4b29912c 100644
--- a/api/_lib/x-content/overlay.js
+++ b/api/_lib/x-content/overlay.js
@@ -555,7 +555,9 @@ export async function resolveRoot({ imageRoot, env = process.env, storage = null
if (env.X_CONTENT_REMOTE_QUEUE !== 'true') return image('X_CONTENT_REMOTE_QUEUE is not true');
try {
secretFrom(env);
- if (!storage && !(await import('../r2.js')).objectStorageConfigured()) return unavailable('object storage is not configured');
+ // A named bucket is Cloud Storage, which needs no R2 credentials at all.
+ const gcs = Boolean(String(env.X_CONTENT_BUNDLE_BUCKET || '').trim());
+ if (!storage && !gcs && !(await import('../r2.js')).objectStorageConfigured()) return unavailable('object storage is not configured');
const store = storage || bundleStorage(env);
const index = await readIndex({ storage: store, env });
if (!index) return image('there is no bundle index in storage');
diff --git a/tests/x-content-overlay.test.js b/tests/x-content-overlay.test.js
index 1df4daa3d..c087c43a8 100644
--- a/tests/x-content-overlay.test.js
+++ b/tests/x-content-overlay.test.js
@@ -557,6 +557,22 @@ describe('resolveRoot', () => {
expect(warn).toHaveBeenCalledWith('[x-content] overlay unavailable, using the image queue', expect.stringMatching(/does not hash/));
});
+
+ it('reads a named Cloud Storage bucket even when R2 is not configured', async () => {
+ quiet();
+ for (const name of ['S3_ENDPOINT', 'S3_BUCKET', 'S3_PUBLIC_DOMAIN', 'S3_ACCESS_KEY_ID', 'S3_SECRET_ACCESS_KEY', 'GCP_SERVICE_ACCOUNT_JSON']) vi.stubEnv(name, '');
+ const asked = [];
+ vi.stubGlobal('fetch', async (url) => {
+ asked.push(String(url));
+ if (String(url).includes('metadata.google.internal')) return new Response(JSON.stringify({ access_token: 'token', expires_in: 3600 }), { status: 200 });
+ return new Response('not found', { status: 404 });
+ });
+ const imageRoot = image();
+ const result = await resolveRoot({ imageRoot, env: { ...env, X_CONTENT_BUNDLE_BUCKET: 'bundles' }, dir: scratch() });
+ vi.unstubAllGlobals();
+ expect(result.reason).toMatch(/no bundle index/);
+ expect(asked.some((url) => url.startsWith('https://storage.googleapis.com/storage/v1/b/bundles/'))).toBe(true);
+ });
});
describe('a tick against the overlay', () => {