{"record":{"id":"d5336cce2049f35a","repo":"n8n-io/n8n","slug":"an-assistant-with-the-same-name-name-already","errorCode":null,"errorMessage":"An assistant with the same name '${name}' already exists","messagePattern":"An assistant with the same name '(.+?)' already exists","errorType":"validation","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v1/actions/assistant/create.operation.ts","lineNumber":220,"sourceCode":"\t\t\t\t\tafter,\n\t\t\t\t},\n\t\t\t})) as { data: IDataObject[]; has_more: boolean; last_id: string };\n\n\t\t\tfor (const assistant of response.data || []) {\n\t\t\t\tassistants.push(assistant.name as string);\n\t\t\t}\n\n\t\t\thas_more = response.has_more;\n\n\t\t\tif (has_more) {\n\t\t\t\tafter = response.last_id;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} while (has_more);\n\n\t\tif (assistants.includes(name)) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t`An assistant with the same name '${name}' already exists`,\n\t\t\t\t{ itemIndex: i },\n\t\t\t);\n\t\t}\n\t}\n\n\tif (file_ids.length > 20) {\n\t\tthrow new NodeOperationError(\n\t\t\tthis.getNode(),\n\t\t\t'The maximum number of files that can be attached to the assistant is 20',\n\t\t\t{ itemIndex: i },\n\t\t);\n\t}\n\n\tconst body: IDataObject = {\n\t\tmodel,\n\t\tname,","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v1/actions/assistant/create.operation.ts#L202-L238","documentation":"Before creating a new OpenAI assistant, the code paginates through all existing assistants (following has_more/last_id pagination) and collects their names. If the requested assistant name already exists on the account, it throws a NodeOperationError to prevent a duplicate. This is a client-side pre-validation check before the POST to /v1/assistants.","triggerScenarios":"The 'Create Assistant' operation is called with a name that matches an existing assistant on the OpenAI account. The code lists all assistants via paginated GET requests, and if the name is found in the list, it aborts before creating.","commonSituations":"Running the same create-assistant workflow multiple times without changing the name; migrating or replaying workflows that create named assistants; accidental duplicate workflow executions.","solutions":["Use a unique assistant name, or append a timestamp/UUID to the name","Delete the existing assistant with the same name from the OpenAI dashboard before re-running","Switch to an 'Update Assistant' operation if the intent is to modify an existing one"],"exampleFix":"// before — name: 'My Assistant'\n// after  — name: `My Assistant ${Date.now()}`","handlingStrategy":"validation","validationCode":"// Check for existing assistant name before creating\nconst existingNames = await listExistingAssistantNames(this);\nif (existingNames.includes(name)) {\n  // Use a unique name or update instead\n  name = `${name}-${Date.now()}`;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await createAssistant(this, i);\n} catch (error) {\n  if (error instanceof NodeOperationError && error.message.includes('already exists')) {\n    // Retry with a unique name or switch to update\n    name = `${name}-${Date.now()}`;\n    await createAssistant(this, i);\n  }\n  throw error;\n}","preventionTips":["Use unique assistant names — append timestamps or UUIDs for programmatic creation","Before creating, list existing assistants and skip or update if the name exists","Use idempotent workflow patterns that check-then-create"],"tags":["openai","assistant","duplicate","pre-validation","v1"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}