{"record":{"id":"4265f80c5965a9be","repo":"github/copilot-sdk","slug":"factory-not-found","errorCode":"factory_not_found","errorMessage":"No factory registered with name \"${params.name}\"","messagePattern":"No factory registered with name \"(.+?)\"","errorType":"error_code","errorClass":"ResponseError","httpStatus":null,"severity":"error","filePath":"nodejs/src/session.ts","lineNumber":1460,"sourceCode":"        }\n\n        for (const handle of factories) {\n            const definition = getFactoryDefinition(handle);\n            if (this.factories.has(definition.meta.name)) {\n                throw new Error(\n                    `Duplicate factory name \"${definition.meta.name}\". Factory names must be unique within a joinSession call.`\n                );\n            }\n            this.factories.set(definition.meta.name, definition);\n        }\n\n        const self = this;\n        this.clientSessionApis.factory = {\n            async execute(params) {\n                const definition = self.factories.get(params.name);\n                if (!definition) {\n                    const message = `No factory registered with name \"${params.name}\"`;\n                    throw new ResponseError(ErrorCodes.InvalidParams, message, {\n                        code: \"factory_not_found\",\n                        name: params.name,\n                    });\n                }\n\n                const controller = new AbortController();\n                // Keyed by execution token as well as run ID so overlapping\n                // attempts for one run stay individually addressable.\n                let controllersForRun = self.factoryAbortControllers.get(params.runId);\n                if (controllersForRun === undefined) {\n                    controllersForRun = new Map();\n                    self.factoryAbortControllers.set(params.runId, controllersForRun);\n                }\n                controllersForRun.set(params.executionToken, controller);\n                const progress = new FactoryProgressBuffer(async (lines) => {\n                    await self.rpc.factory.log({\n                        runId: params.runId,\n                        executionToken: params.executionToken,","sourceCodeStart":1442,"sourceCodeEnd":1478,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/nodejs/src/session.ts#L1442-L1478","documentation":"Thrown by CopilotSession when the client invokes the `factory.execute` session API with a `name` that has no corresponding factory registered via the session's factory registry (a Map lookup misses). The SDK throws a ResponseError with ErrorCodes.InvalidParams and a machine-readable `code: \"factory_not_found\"`. It prevents silently executing an undefined workflow.","triggerScenarios":"Calling session factory execute API with a factory name that was never registered, or registered under a different name; a typo in the factory name; executing a factory after the registration code path never ran.","commonSituations":"Typos or casing mismatches between registerFactory and execute calls; registration code skipped because of conditional init; factories registered on a different CopilotSession instance than the one executing.","solutions":["List the registered factory names and confirm the exact key (case-sensitive) before executing","Register the factory with the exact name being requested via the session's factory registration API","Fix the name passed to factory.execute so it matches the registration","Ensure registration happens on the same session instance and before any execute call"],"exampleFix":"// before\nawait session.factory.execute({ name: \"deploy-app\" });\n// after\nsession.registerFactory(\"deploy-app\", { run: async (ctx) => { /* ... */ } });\nawait session.factory.execute({ name: \"deploy-app\" });","handlingStrategy":"validation","validationCode":"const names = session.listFactories?.() ?? [];\nif (!names.includes(params.name)) throw new Error(`Unknown factory: ${params.name}`);","typeGuard":"function hasFactory(session, name) {\n  return typeof session.listFactories === \"function\" && session.listFactories().includes(name);\n}","tryCatchPattern":"try {\n  await session.factory.execute({ name });\n} catch (err) {\n  if (err?.code === \"factory_not_found\") {\n    console.error(`Factory \"${err.data?.name}\" is not registered; check registration order/naming.`);\n  } else throw err;\n}","preventionTips":["Keep factory names in a shared constants module used by both registration and execution","Log registered factory names at session startup","Register all factories immediately after session construction, before any execute call"],"tags":["factory","registry","invalid-params"],"backgroundTag":"resource-not-found","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}