n8n-io/n8n · warning · BadRequestError
Malformed binary data ID
Error message
Malformed binary data ID
What it means
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.
Source
Thrown at packages/cli/src/controllers/binary-data.controller.ts:58
await this.setContentHeaders(binaryDataId, 'download', res);
return await this.binaryDataService.getAsStream(binaryDataId);
} catch (error) {
if (error instanceof FileNotFoundError) return res.status(404).end();
if (error instanceof BadRequestError || error instanceof JsonWebTokenError)
return res.status(400).end(error.message);
else throw error;
}
}
private validateBinaryDataId(binaryDataId: string) {
if (!binaryDataId) {
throw new BadRequestError('Missing binary data ID');
}
const separatorIndex = binaryDataId.indexOf(':');
if (separatorIndex === -1) {
throw new BadRequestError('Malformed binary data ID');
}
const mode = binaryDataId.substring(0, separatorIndex);
if (!isValidNonDefaultMode(mode)) {
throw new BadRequestError('Invalid binary data mode');
}
const path = binaryDataId.substring(separatorIndex + 1);
if (path === '' || path === '/' || path === '//') {
throw new BadRequestError('Malformed binary data ID');
}
}
private async setContentHeaders(
binaryDataId: string,
action: 'view' | 'download',View on GitHub (pinned to 5ac6606e81)
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.
Example fix
// before GET /binary-data?id=abc // 400 Malformed binary data ID // after GET /binary-data?id=s3:exec-123/binary-0
Defensive patterns
Strategy: validation
Validate before calling
function hasSeparator(id: string) { return id.includes(':'); }
// if (!hasSeparator(id)) throw new TypeError('id must be <mode>:<path>') Type guard
const isShapedId = (id: unknown): id is string =>
typeof id === 'string' && id.indexOf(':') !== -1; Try / catch
try { await get(req); } catch (e) { if (e instanceof BadRequestError && /Malformed/.test(e.message)) {/* rebuild id */} } Prevention
- Derive binary IDs from execution `binary` data, not from execution IDs.
- Add a unit test asserting the `mode:path` shape for any ID builder.
When it happens
Trigger: Passing a bare UUID, an execution ID, or any string without a colon as `id`. E.g. `?id=exec-123` or `?id=abc`.
Common situations: Clients confusing the execution ID with the binary data ID; legacy integrations that assumed raw IDs; copy-paste truncation dropping the path half.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- error.message
- Missing binary data ID
- Invalid binary data mode
- Content not viewable
- output.error.errors[0]
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/f51ec3ed060ee23e.
Report an issue: GitHub.