langfuse/langfuse · error · InvalidRequestError
File size must be less than ${env.LANGFUSE_S3_MEDIA_MAX_CONT
Error message
File size must be less than ${env.LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH} bytes What it means
The requested contentLength exceeds LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH, the server-configured maximum media file size for S3-backed media storage.
Source
Thrown at web/src/pages/api/public/media/index.ts:41
"Ingestion suspended: Usage threshold exceeded. Please upgrade your plan.",
);
}
if (auth.scope.accessLevel !== "project") throw new ForbiddenError();
const { projectId } = auth.scope;
const {
contentLength,
sha256Hash,
traceId,
observationId,
datasetId,
datasetItemId,
field,
} = body;
if (contentLength > env.LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH)
throw new InvalidRequestError(
`File size must be less than ${env.LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH} bytes`,
);
return await instrumentAsync(
{ name: "media-create-upload-url" },
async (span) => {
span.setAttribute("projectId", projectId);
span.setAttribute("traceId", traceId ?? "");
span.setAttribute("observationId", observationId ?? "");
span.setAttribute("datasetId", datasetId ?? "");
span.setAttribute("datasetItemId", datasetItemId ?? "");
span.setAttribute("field", field ?? "");
span.setAttribute("sha256Hash", sha256Hash);
const result = await createMediaUploadUrl({ projectId, body });
span.setAttribute("mediaId", result.mediaId);
return result;View on GitHub (pinned to 59d92c7cf3)
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
Example fix
# before LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH=1048576 # after (self-hosted) LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH=10485760
Defensive patterns
Strategy: validation
Validate before calling
const MAX = Number(process.env.LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH ?? 1048576);
if (statSync(file).size > MAX) throw new Error(`file exceeds ${MAX} bytes`); Type guard
const fitsMediaLimit = (size: number, max = 1048576) => size <= max;
Prevention
- Compress images/audio before upload
- Self-hosted: keep LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH in sync with bucket/CDN limits
When it happens
Trigger: Requesting an upload URL for a file larger than the configured cap (commonly ~1MB–10MB depending on env; larger defaults require custom S3 config).
Common situations: Uploading large images/audio and hitting the default limit; self-hosters raising LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH or Langfuse Cloud's fixed cap.
Related errors
- File size must be less than ${env.LANGFUSE_S3_MEDIA_MAX_CONT
- Invalid dataset item input
- invalid-request
- protocol-not-allowed
- protocol-not-allowed
AI-assisted analysis of langfuse/langfuse@59d92c7cf3 (2026-08-27).
Data as JSON: /api/errors/f6e56d9fb533eb3a.
Report an issue: GitHub.