{"record":{"id":"f6e56d9fb533eb3a","repo":"langfuse/langfuse","slug":"file-size-must-be-less-than-env-langfuse-s3-medi-f6e56d","errorCode":null,"errorMessage":"File size must be less than ${env.LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH} bytes","messagePattern":"File size must be less than (.+?) bytes","errorType":"exception","errorClass":"InvalidRequestError","httpStatus":400,"severity":"error","filePath":"web/src/pages/api/public/media/index.ts","lineNumber":41,"sourceCode":"          \"Ingestion suspended: Usage threshold exceeded. Please upgrade your plan.\",\n        );\n      }\n\n      if (auth.scope.accessLevel !== \"project\") throw new ForbiddenError();\n\n      const { projectId } = auth.scope;\n      const {\n        contentLength,\n        sha256Hash,\n        traceId,\n        observationId,\n        datasetId,\n        datasetItemId,\n        field,\n      } = body;\n\n      if (contentLength > env.LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH)\n        throw new InvalidRequestError(\n          `File size must be less than ${env.LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH} bytes`,\n        );\n\n      return await instrumentAsync(\n        { name: \"media-create-upload-url\" },\n        async (span) => {\n          span.setAttribute(\"projectId\", projectId);\n          span.setAttribute(\"traceId\", traceId ?? \"\");\n          span.setAttribute(\"observationId\", observationId ?? \"\");\n          span.setAttribute(\"datasetId\", datasetId ?? \"\");\n          span.setAttribute(\"datasetItemId\", datasetItemId ?? \"\");\n          span.setAttribute(\"field\", field ?? \"\");\n          span.setAttribute(\"sha256Hash\", sha256Hash);\n\n          const result = await createMediaUploadUrl({ projectId, body });\n          span.setAttribute(\"mediaId\", result.mediaId);\n\n          return result;","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/langfuse/langfuse/blob/59d92c7cf365150d10b753b5a0d1708902a2ed60/web/src/pages/api/public/media/index.ts#L23-L59","documentation":"The requested contentLength exceeds LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH, the server-configured maximum media file size for S3-backed media storage.","triggerScenarios":"Requesting an upload URL for a file larger than the configured cap (commonly ~1MB–10MB depending on env; larger defaults require custom S3 config).","commonSituations":"Uploading large images/audio and hitting the default limit; self-hosters raising LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH or Langfuse Cloud's fixed cap.","solutions":["Compress/resize the asset below the limit","On self-hosted: set LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH (and ensure S3 bucket policy matches) and restart web","Stream only smaller artifacts as media; store larger ones externally"],"exampleFix":"# before\nLANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH=1048576\n\n# after (self-hosted)\nLANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH=10485760","handlingStrategy":"validation","validationCode":"const MAX = Number(process.env.LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH ?? 1048576);\nif (statSync(file).size > MAX) throw new Error(`file exceeds ${MAX} bytes`);","typeGuard":"const fitsMediaLimit = (size: number, max = 1048576) => size <= max;","tryCatchPattern":null,"preventionTips":["Compress images/audio before upload","Self-hosted: keep LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH in sync with bucket/CDN limits"],"tags":["media","file-size","s3","configuration"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"59d92c7cf365150d10b753b5a0d1708902a2ed60","analyzedAt":"2026-08-27T22:22:00.402Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}