{"record":{"id":"141e04ec331b4fa9","repo":"n8n-io/n8n","slug":"provider-connection-data-cannot-be-empty","errorCode":null,"errorMessage":"Provider connection data cannot be empty","messagePattern":"Provider connection data cannot be empty","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/import/credentials.ts","lineNumber":258,"sourceCode":"\n\tprivate async validateInstanceCredentialData(\n\t\ttransactionManager: EntityManager,\n\t\tcredential: Partial<CredentialsEntity>,\n\t\texisting: Pick<CredentialsEntity, 'id' | 'type' | 'usageScope'> | null,\n\t\tctx: OperationContext,\n\t) {\n\t\tlet data: unknown = credential.data;\n\t\tif (data === undefined && credential.id) {\n\t\t\tdata = (\n\t\t\t\tawait transactionManager.findOne(CredentialsEntity, {\n\t\t\t\t\twhere: { id: credential.id },\n\t\t\t\t\tselect: { data: true },\n\t\t\t\t})\n\t\t\t)?.data;\n\t\t}\n\t\tif (data === undefined) return;\n\t\tif (data === null || data === '') {\n\t\t\tthrow new UserError('Provider connection data cannot be empty');\n\t\t}\n\n\t\tconst decrypted =\n\t\t\ttypeof data === 'string'\n\t\t\t\t? jsonParse<unknown>(await Container.get(Cipher).decryptV2(data))\n\t\t\t\t: data;\n\t\tif (!isCredentialData(decrypted)) {\n\t\t\tthrow new UserError('Provider connection data must be a JSON object');\n\t\t}\n\t\tconst credentialsService = Container.get(CredentialsService);\n\t\tif (existing?.usageScope === 'instance') {\n\t\t\tawait credentialsService.validateInstanceCredentialUpdate(\n\t\t\t\texisting,\n\t\t\t\tdecrypted,\n\t\t\t\tundefined,\n\t\t\t\tctx,\n\t\t\t);\n\t\t} else {","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/commands/import/credentials.ts#L240-L276","documentation":"Thrown by validateInstanceCredentialData when an instance-scope credential's `data` field is null or an empty string. Instance credentials require a non-empty JSON data payload — they cannot be placeholders.","triggerScenarios":"Import JSON has `usageScope: \"instance\"` and either `data: null`, `data: \"\"`, or the existing DB row's data (fetched at credentials.ts:248-254 when import data is undefined) is null/empty.","commonSituations":"Export that stripped data for security; partial import updating only metadata of an instance credential whose DB row has null data; hand-editing a credential JSON and clearing the data field.","solutions":["Provide a valid non-empty `data` object in the import JSON for the instance credential.","If updating only some fields, ensure the existing DB credential has non-empty data — repair it first via the UI."],"exampleFix":"// before\n{ \"id\": \"x\", \"usageScope\": \"instance\", \"data\": null }\n// after\n{ \"id\": \"x\", \"usageScope\": \"instance\", \"data\": { \"apiKey\": \"...\" } }","handlingStrategy":"validation","validationCode":"function hasNonEmptyData(c: Partial<CredentialsEntity>): boolean {\n  if (c.usageScope !== 'instance') return true;\n  return c.data !== null && c.data !== '' && c.data !== undefined;\n}\nif (!hasNonEmptyData(credential)) {\n  throw new Error('Instance credential requires non-empty data');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include a populated `data` object for instance credentials in import JSON.","Don't strip the data field during export if you intend to re-import as instance scope."],"tags":["cli","import","credentials","instance-scope","validation","data","user-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}