{"record":{"id":"21be4f2e4b1d56fe","repo":"n8n-io/n8n","slug":"failed-to-find-owner-um-fix-instruction","errorCode":null,"errorMessage":"Failed to find owner. ${UM_FIX_INSTRUCTION}","messagePattern":"Failed to find owner\\. (.+?)","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/import/credentials.ts","lineNumber":505,"sourceCode":"\t}\n\n\tprivate async credentialExists(transactionManager: EntityManager, credentialId: string) {\n\t\treturn await transactionManager.existsBy(CredentialsEntity, { id: credentialId });\n\t}\n\n\tprivate async getProject(transactionManager: EntityManager, userId?: string, projectId?: string) {\n\t\tif (projectId) {\n\t\t\treturn await transactionManager.findOneByOrFail(Project, { id: projectId });\n\t\t}\n\n\t\tif (!userId) {\n\t\t\tconst owner = await transactionManager.findOneBy(User, {\n\t\t\t\trole: {\n\t\t\t\t\tslug: GLOBAL_OWNER_ROLE.slug,\n\t\t\t\t},\n\t\t\t});\n\t\t\tif (!owner) {\n\t\t\t\tthrow new UserError(`Failed to find owner. ${UM_FIX_INSTRUCTION}`);\n\t\t\t}\n\t\t\tuserId = owner.id;\n\t\t}\n\n\t\treturn await Container.get(ProjectRepository).getPersonalProjectForUserOrFail(\n\t\t\tuserId,\n\t\t\ttransactionManager,\n\t\t);\n\t}\n}\n","sourceCodeStart":487,"sourceCodeEnd":516,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/commands/import/credentials.ts#L487-L516","documentation":"Thrown by getProject in import:credentials when neither --userId nor --projectId is supplied AND no global owner user exists in the DB. Without an explicit assignment target, n8n falls back to the global owner's personal project; if that user is missing the import cannot proceed. UM_FIX_INSTRUCTION is the string: 'Please fix the database by running ./packages/cli/bin/n8n user-management:reset'.","triggerScenarios":"`n8n import:credentials --input=f.json` (no owner flags) on a DB where the global owner role has no user row. Common after a partial DB wipe, a corrupted user-management setup, or importing into a DB that was never fully initialised.","commonSituations":"Fresh DB where owner setup was skipped; DB restored from a backup missing the owner row; migrations that touched the user/role tables.","solutions":["Run `n8n user-management:reset` to recreate the owner account (this is the message's literal instruction).","Alternatively supply `--userId=<existing-user-id>` or `--projectId=<existing-project-id>` to bypass the owner lookup."],"exampleFix":"// before — fails because no owner row exists\nn8n import:credentials --input=f.json\n// after — recreate owner, then import\nn8n user-management:reset\nn8n import:credentials --input=f.json","handlingStrategy":"validation","validationCode":"async function ownerExists(ds: DataSource): Promise<boolean> {\n  return await ds.getRepository('user').exist({ where: { role: { slug: 'owner' } } });\n}\nif (!flags.userId && !flags.projectId && !(await ownerExists(ds))) {\n  throw new Error('No global owner — run: n8n user-management:reset');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run `n8n user-management:reset` after restoring a DB from backup.","In CI/scripts, pass --projectId explicitly to avoid relying on the owner row."],"tags":["cli","import","credentials","owner","user-management","database","user-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}