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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(storage): treat a revoked R2 key as infrastructure so the public-domain failover fires
nirholas8be6f6def200
diff --git a/api/_lib/r2.js b/api/_lib/r2.jsindex 188f7a37e..ba8aca0aa 100644--- a/api/_lib/r2.js+++ b/api/_lib/r2.js@@ -78,8 +78,16 @@ export function objectStorageConfigured() {// caller of this helper, including the batch runners that use it to decide// whether an asset is blameless, and surfaced to users as a raw "Check your// secret access key" in the browser.+// `unauthorized` covers the OTHER shape a bad token takes: a ROTATED secret+// answers SignatureDoesNotMatch, but a REVOKED or deleted access key id answers+// a bare `Unauthorized` instead, which nothing here matched. That gap is+// invisible until it fires, because both faults present identically to a user+// and only one of them reached the public-domain failover in cdn-object.js and+// the avatar GLB proxy. Object-level denial is `AccessDenied` (already listed+// above), so `Unauthorized` from S3 is always the credential and never the+// object: classifying it as infrastructure blames nothing that deserves blame.export const STORAGE_ERROR_PATTERN =- 'missing required env var: s3_|invalidaccesskeyid|signaturedoesnotmatch|does not match the signature|nosuchbucket|access denied|econnrefused|enotfound|socket hang up|econnreset';+ 'missing required env var: s3_|invalidaccesskeyid|signaturedoesnotmatch|does not match the signature|unauthorized|nosuchbucket|access denied|econnrefused|enotfound|socket hang up|econnreset';const STORAGE_ERROR_RE = new RegExp(STORAGE_ERROR_PATTERN, 'i');diff --git a/api/avatars/[id]/[action].js b/api/avatars/[id]/[action].jsindex 5bc45cd61..f70cf0db7 100644--- a/api/avatars/[id]/[action].js+++ b/api/avatars/[id]/[action].js@@ -728,6 +728,14 @@ async function handleGlb(req, res) {} catch (fallbackErr) {console.error('[avatars/glb] public bucket domain failed too:', key, fallbackErr?.message);if (res.headersSent) return res.destroy(fallbackErr);+ // Nothing has been written yet, so the 502 below still gets to+ // answer, but only if the GLB's own length and etag come back+ // off first. json() refuses to touch a committed response and+ // never clears headers, so leaving content-length behind would+ // pin the error body to the model's byte count and hang the+ // client waiting for megabytes that are never coming.+ res.removeHeader('content-length');+ res.removeHeader('etag');}}console.error('[avatars/glb] r2 fetch failed:', err);diff --git a/tests/thumbnail-blameless-failures.test.js b/tests/thumbnail-blameless-failures.test.jsindex f16845357..dc725eb3a 100644--- a/tests/thumbnail-blameless-failures.test.js+++ b/tests/thumbnail-blameless-failures.test.js@@ -32,6 +32,15 @@ describe('blameless render failures', () => {expect(blameless(new Error('Missing required env var: S3_BUCKET'))).toBe(true);expect(blameless(new Error('Missing required env var: S3_ACCESS_KEY_ID'))).toBe(true);expect(blameless(new Error('InvalidAccessKeyId'))).toBe(true);+ // A bad R2 token has two shapes and only one of them used to match. A+ // rotated secret answers SignatureDoesNotMatch; a revoked or deleted+ // access key id answers a bare Unauthorized, which slipped past every+ // caller, including the public-domain failover in cdn-object.js and the+ // avatar GLB proxy. Object-level denial is AccessDenied, so Unauthorized+ // from S3 is always the credential.+ expect(blameless(new Error('Unauthorized'))).toBe(true);+ expect(blameless({ name: 'Unauthorized', Code: 'Unauthorized' })).toBe(true);+ expect(blameless(new Error('SignatureDoesNotMatch'))).toBe(true);expect(blameless(new Error('NoSuchBucket: the bucket does not exist'))).toBe(true);expect(blameless({ message: 'connect ECONNREFUSED 10.0.0.1:443' })).toBe(true);});