{"record":{"id":"7a1bdf664b5e5c7e","repo":"remotion-dev/remotion","slug":"the-filename-must-not-be-empty","errorCode":null,"errorMessage":"The `filename` must not be empty","messagePattern":"The `filename` must not be empty","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/validation/validate-artifact.ts","lineNumber":11,"sourceCode":"import type {TRenderAsset} from '../CompositionManager';\n\nexport const validateArtifactFilename = (filename: unknown) => {\n\tif (typeof filename !== 'string') {\n\t\tthrow new TypeError(\n\t\t\t`The \"filename\" must be a string, but you passed a value of type ${typeof filename}`,\n\t\t);\n\t}\n\n\tif (filename.trim() === '') {\n\t\tthrow new Error('The `filename` must not be empty');\n\t}\n\n\tif (!filename.match(/^([0-9a-zA-Z-!_.*'()/:&$@=;+,?]+)/g)) {\n\t\tthrow new Error(\n\t\t\t'The `filename` must match \"/^([0-9a-zA-Z-!_.*\\'()/:&$@=;+,?]+)/g\". Use forward slashes only, even on Windows.',\n\t\t);\n\t}\n};\n\nconst validateContent = (content: unknown) => {\n\tif (typeof content !== 'string' && !(content instanceof Uint8Array)) {\n\t\tthrow new TypeError(\n\t\t\t`The \"content\" must be a string or Uint8Array, but you passed a value of type ${typeof content}`,\n\t\t);\n\t}\n\n\tif (typeof content === 'string' && content.trim() === '') {\n\t\tthrow new Error('The `content` must not be empty');","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/validation/validate-artifact.ts#L1-L29","documentation":"After confirming the artifact filename is a string, validateArtifactFilename rejects empty or whitespace-only filenames because they cannot identify a file in the output directory and would collide or be silently dropped by the filesystem.","triggerScenarios":"Registering an artifact with filename=\"\", filename=\"   \", or a value that becomes empty after trim() (e.g. a template literal that resolves to only spaces).","commonSituations":"Building a filename from optional fields that are all undefined, producing an empty string; trimming user input that turns out to be blank; a default value of '' used before a real name is assigned.","solutions":["Provide a non-empty, meaningful filename: {filename: 'report.json', content: '...'}.","If the filename is built dynamically, fall back to a default when empty: filename = name || 'artifact.bin'.","Validate the generated filename is non-empty after trim() before registering the artifact."],"exampleFix":"// before\nconst filename = `${prefix}-${suffix}`; // both undefined -> '-'\nregisterRenderAsset({type: 'artifact', filename: filename.trim(), content});\n// after\nconst filename = `${prefix ?? 'artifact'}-${suffix ?? Date.now()}.bin`;\nregisterRenderAsset({type: 'artifact', filename, content});","handlingStrategy":"validation","validationCode":"if (typeof filename !== 'string' || filename.trim() === '') {\n  throw new Error('filename must be a non-empty string');\n}","typeGuard":"const isNonEmptyFilename = (v: unknown): v is string =>\n  typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":null,"preventionTips":["Provide a sensible default when building filenames from optional fields.","Assert filename.trim() is non-empty before registering the artifact.","Avoid defaulting filename variables to ''; use undefined and fall back to a real name."],"tags":["validation","artifacts","rendering","filename"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}