{"record":{"id":"2655bc12254be711","repo":"n8n-io/n8n","slug":"invalid-binary-data-mode","errorCode":null,"errorMessage":"Invalid binary data mode","messagePattern":"Invalid binary data mode","errorType":"exception","errorClass":"BadRequestError","httpStatus":400,"severity":"warning","filePath":"packages/cli/src/controllers/binary-data.controller.ts","lineNumber":64,"sourceCode":"\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',\n\t\tres: Response,\n\t\tfileName?: string,\n\t\tmimeType?: string,\n\t) {\n\t\ttry {\n\t\t\tconst metadata = await this.binaryDataService.getMetadata(binaryDataId);","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/controllers/binary-data.controller.ts#L46-L82","documentation":"BadRequestError (HTTP 400) 'Invalid binary data mode' thrown at binary-data.controller.ts:64 when the prefix before the `:` is not one of the recognized stored modes. Valid modes (from `STORED_MODES`) are: `filesystem`, `filesystem-v2`, `s3`, `azure`, `database` — `default` is explicitly excluded by `isValidNonDefaultMode`.","triggerScenarios":"Passing `id=default:...` or any unknown prefix (`id=gcs:...`, `id=foo:...`). Common when an instance was running in `default` mode and a caller stored the legacy ID, or when the storage backend was reconfigured.","commonSituations":"Upgrading/migrating binary storage mode; mixing instances with different `N8N_DEFAULT_BINARY_DATA_MODE`; clients assuming a mode the deployment doesn't use.","solutions":["Use a mode that matches the deployment's `N8N_DEFAULT_BINARY_DATA_MODE` (or one of: filesystem, filesystem-v2, s3, azure, database).","After migrating binary storage, re-run executions so IDs carry the new mode prefix.","Never emit `default:` IDs — `default` is a sentinel, not a stored mode."],"exampleFix":"// before\nGET /binary-data?id=default:exec-123/data\n// 400 Invalid binary data mode\n\n// after\nGET /binary-data?id=filesystem-v2:exec-123/data","handlingStrategy":"validation","validationCode":"const MODES = ['filesystem','filesystem-v2','s3','azure','database'] as const;\nfunction validMode(id: string) {\n  const m = id.slice(0, id.indexOf(':'));\n  return (MODES as readonly string[]).includes(m);\n}\n// guard the fetch: if (!validMode(id)) rebuild id with the deployment's mode","typeGuard":"const STORED_MODES = ['filesystem','filesystem-v2','s3','azure','database'] as const;\ntype StoredMode = typeof STORED_MODES[number];\nconst isStoredMode = (m: string): m is StoredMode => (STORED_MODES as readonly string[]).includes(m);","tryCatchPattern":"try { await get(req); } catch (e) { if (e instanceof BadRequestError && /Invalid binary data mode/.test(e.message)) {/* map to configured mode */} }","preventionTips":["Use the deployment's actual N8N_DEFAULT_BINARY_DATA_MODE when emitting IDs.","After migrating storage mode, re-run executions so IDs carry the new prefix.","Never store `default:` IDs externally — `default` is a runtime sentinel."],"tags":["binary-data","rest","bad-request","storage-mode","validation"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}