{"record":{"id":"7a3fcbeaa021244f","repo":"n8n-io/n8n","slug":"file-does-not-seem-to-contain-credentials-make-su","errorCode":null,"errorMessage":"File does not seem to contain credentials. Make sure the credentials are contained in an array.","messagePattern":"File does not seem to contain credentials\\. Make sure the credentials are contained in an array\\.","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/import/credentials.ts","lineNumber":365,"sourceCode":"\n\t\tlet credentials: Array<Partial<CredentialsEntity>>;\n\n\t\tif (separate) {\n\t\t\tconst files = await glob('*.json', {\n\t\t\t\tcwd: inputPath,\n\t\t\t\tabsolute: true,\n\t\t\t});\n\n\t\t\tcredentials = files.map((file) =>\n\t\t\t\tjsonParse<Partial<CredentialsEntity>>(fs.readFileSync(file, { encoding: 'utf8' })),\n\t\t\t);\n\t\t} else {\n\t\t\tconst credentialsUnchecked = jsonParse<Array<Partial<CredentialsEntity>>>(\n\t\t\t\tfs.readFileSync(inputPath, { encoding: 'utf8' }),\n\t\t\t);\n\n\t\t\tif (!Array.isArray(credentialsUnchecked)) {\n\t\t\t\tthrow new UserError(\n\t\t\t\t\t'File does not seem to contain credentials. Make sure the credentials are contained in an array.',\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tcredentials = credentialsUnchecked;\n\t\t}\n\n\t\tconst knownProperties = new Set(credentials.flatMap((credential) => Object.keys(credential)));\n\t\tthis.warnOnUnknownProperties(include, knownProperties, '--include');\n\t\tthis.warnOnUnknownProperties(exclude, knownProperties, '--exclude');\n\n\t\treturn await Promise.all(\n\t\t\tcredentials.map(async (credential) => {\n\t\t\t\tconst filteredCredential = this.filterCredentialProperties(credential, include, exclude);\n\t\t\t\tif (isCredentialData(filteredCredential.data)) {\n\t\t\t\t\t// plain data / decrypted input. Should be encrypted first.\n\t\t\t\t\tfilteredCredential.data = await cipher.encryptV2(filteredCredential.data);\n\t\t\t\t}","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/commands/import/credentials.ts#L347-L383","documentation":"Thrown by readCredentials when not using `--separate`: the JSON file parsed but is not an array. The single-file credential import format requires an array of credential objects, even for a single credential.","triggerScenarios":"`n8n import:credentials --input=f.json` where f.json contains a bare object `{...}` instead of `[{...}]`, or a non-credential JSON structure.","commonSituations":"Hand-editing an export down to a single object and forgetting the brackets; pulling a credential from an API that returns an object; using a workflow export file by mistake.","solutions":["Wrap the credential object in an array: `[{ ... }]`.","Alternatively use `--separate --input=dir/` where each file is one credential object."],"exampleFix":"// before — f.json\n{ \"id\": \"x\", \"name\": \"...\" }\n// after — f.json\n[ { \"id\": \"x\", \"name\": \"...\" } ]","handlingStrategy":"type-guard","validationCode":"function parseCredentialsFile(raw: string): Array<Partial<CredentialsEntity>> {\n  const parsed = JSON.parse(raw);\n  if (!Array.isArray(parsed)) {\n    throw new Error('Credentials file must contain a JSON array');\n  }\n  return parsed;\n}","typeGuard":"const isCredentialsArray = (v: unknown): v is Array<Record<string, unknown>> =>\n  Array.isArray(v) && v.every(item => typeof item === 'object' && item !== null);","tryCatchPattern":null,"preventionTips":["Always wrap credentials in an array in export/import files, even for a single credential.","Use --separate mode (one object per file) to avoid the array requirement."],"tags":["cli","import","credentials","file-format","validation","user-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}