{"record":{"id":"f51ec3ed060ee23e","repo":"n8n-io/n8n","slug":"malformed-binary-data-id","errorCode":null,"errorMessage":"Malformed binary data ID","messagePattern":"Malformed binary data ID","errorType":"exception","errorClass":"BadRequestError","httpStatus":400,"severity":"warning","filePath":"packages/cli/src/controllers/binary-data.controller.ts","lineNumber":58,"sourceCode":"\t\t\tawait this.setContentHeaders(binaryDataId, 'download', res);\n\t\t\treturn await this.binaryDataService.getAsStream(binaryDataId);\n\t\t} catch (error) {\n\t\t\tif (error instanceof FileNotFoundError) return res.status(404).end();\n\t\t\tif (error instanceof BadRequestError || error instanceof JsonWebTokenError)\n\t\t\t\treturn res.status(400).end(error.message);\n\t\t\telse throw error;\n\t\t}\n\t}\n\n\tprivate validateBinaryDataId(binaryDataId: string) {\n\t\tif (!binaryDataId) {\n\t\t\tthrow new BadRequestError('Missing binary data ID');\n\t\t}\n\n\t\tconst separatorIndex = binaryDataId.indexOf(':');\n\n\t\tif (separatorIndex === -1) {\n\t\t\tthrow new BadRequestError('Malformed binary data ID');\n\t\t}\n\n\t\tconst mode = binaryDataId.substring(0, separatorIndex);\n\n\t\tif (!isValidNonDefaultMode(mode)) {\n\t\t\tthrow new BadRequestError('Invalid binary data mode');\n\t\t}\n\n\t\tconst path = binaryDataId.substring(separatorIndex + 1);\n\n\t\tif (path === '' || path === '/' || path === '//') {\n\t\t\tthrow new BadRequestError('Malformed binary data ID');\n\t\t}\n\t}\n\n\tprivate async setContentHeaders(\n\t\tbinaryDataId: string,\n\t\taction: 'view' | 'download',","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/controllers/binary-data.controller.ts#L40-L76","documentation":"BadRequestError (HTTP 400) 'Malformed binary data ID' thrown at binary-data.controller.ts:58 when the `id` contains no `:` separator — i.e. it is not in the required `<mode>:<path>` shape. `binaryDataId.indexOf(':')` returns -1.","triggerScenarios":"Passing a bare UUID, an execution ID, or any string without a colon as `id`. E.g. `?id=exec-123` or `?id=abc`.","commonSituations":"Clients confusing the execution ID with the binary data ID; legacy integrations that assumed raw IDs; copy-paste truncation dropping the path half.","solutions":["Use the full binary ID `<mode>:<path>` emitted by the execution's `binary` field.","Construct IDs from the API response, not from execution metadata."],"exampleFix":"// before\nGET /binary-data?id=abc\n// 400 Malformed binary data ID\n\n// after\nGET /binary-data?id=s3:exec-123/binary-0","handlingStrategy":"validation","validationCode":"function hasSeparator(id: string) { return id.includes(':'); }\n// if (!hasSeparator(id)) throw new TypeError('id must be <mode>:<path>')","typeGuard":"const isShapedId = (id: unknown): id is string =>\n  typeof id === 'string' && id.indexOf(':') !== -1;","tryCatchPattern":"try { await get(req); } catch (e) { if (e instanceof BadRequestError && /Malformed/.test(e.message)) {/* rebuild id */} }","preventionTips":["Derive binary IDs from execution `binary` data, not from execution IDs.","Add a unit test asserting the `mode:path` shape for any ID builder."],"tags":["binary-data","rest","bad-request","validation"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}