{"record":{"id":"e3d8c4f7f2f69fe7","repo":"nocobase/nocobase","slug":"you-want-to-edit-a-collection-definition-but-ther","errorCode":null,"errorMessage":"You want to edit a collection definition, but there is no existing data table definition named '${options.name}'.","messagePattern":"You want to edit a collection definition, but there is no existing data table definition named '(.+?)'\\.","errorType":"exception","errorClass":"IntentError","httpStatus":null,"severity":"error","filePath":"packages/plugins/@nocobase/plugin-data-source-manager/src/ai/ai-employees/orin/skills/data-modeling/tools/defineCollections.ts","lineNumber":202,"sourceCode":"          }\n          if (options.updatedAt !== false) {\n            systemFields.push(updatedAtField);\n            options.updatedAt = true;\n          }\n          if (options.createdBy) {\n            systemFields.push(createdByField);\n            options.createdBy = true;\n          }\n          if (options.updatedBy) {\n            systemFields.push(updatedByField);\n            options.updatedBy = true;\n          }\n\n          const baseFields = [...systemFields, ...normalFields];\n          const collection = await repo.findOne({ filter: { name: options.name }, transaction });\n          if (!collection) {\n            if (intent === 'edit') {\n              throw new IntentError(\n                `You want to edit a collection definition, but there is no existing data table definition named '${options.name}'.`,\n              );\n            }\n            await repo.create({\n              values: { ...options, fields: baseFields },\n              transaction,\n              context: ctx,\n            });\n          } else {\n            if (intent === 'create') {\n              throw new IntentError(\n                `You want to create a collection definition, but a collection definition named '${options.name}' already exists. Please change the name of your collection definition and then invoke this tool again.`,\n              );\n            }\n            await repo.update({\n              filterByTk: options.name,\n              values: _.omit(options, ['fields']),\n              transaction,","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/nocobase/nocobase/blob/fa42722fefe44265490dff2c27d79e2882bce4fa/packages/plugins/@nocobase/plugin-data-source-manager/src/ai/ai-employees/orin/skills/data-modeling/tools/defineCollections.ts#L184-L220","documentation":"The orin data-modeling defineCollections tool throws IntentError when intent is 'edit' but no collection definition with options.name exists in the collections repository. The tool distinguishes create vs edit intent and refuses to silently turn an edit into a create.","triggerScenarios":"Invoking the defineCollections AI tool (or the LLM doing so) with intent 'edit' for a collection name that was never created (or was deleted/renamed).","commonSituations":"The AI guessed an edit intent on a misspelled collection name; the collection lives in a different data source than the tool's repository; schema state was reset between sessions.","solutions":["Re-invoke the tool with intent 'create' since the collection does not exist yet.","Correct the collection name to the existing one before editing.","List existing collections (e.g. via the data-metadata tools) to confirm the actual name first."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const existing = await ctx.db.getRepository('collections').findOne({ filter: { name } });\nconst intent = existing ? 'edit' : 'create';\nawait defineCollectionsTool.invoke(ctx, { intent, name, fields });","typeGuard":null,"tryCatchPattern":"try {\n  await tool.invoke(ctx, args);\n} catch (e) {\n  if (e.name === 'IntentError' && e.message.includes('no existing data table definition')) {\n    await tool.invoke(ctx, { ...args, intent: 'create' });\n  } else throw e;\n}","preventionTips":["Verify the collection exists (repository findOne or getCollectionNames tool) before choosing 'edit' intent.","Derive intent from existence rather than hardcoding it.","Check for typos in collection names supplied to the tool.","Confirm you are querying the correct data source."],"tags":["ai-tools","intent-mismatch","collections"],"backgroundTag":"intent-collection-not-found","analyzedSha":"fa42722fefe44265490dff2c27d79e2882bce4fa","analyzedAt":"2026-09-01T00:54:31.202Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}