{"record":{"id":"6b3b55ee9a9e7c0f","repo":"moeru-ai/airi","slug":"module-moduleid-was-not-found","errorCode":null,"errorMessage":"Module `${moduleId}` was not found.","messagePattern":"Module `(.+?)` was not found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugin-sdk/src/plugin-host/core.ts","lineNumber":562,"sourceCode":"    contribution.install(this.installContext)\n  }\n\n  private async cleanupExtensionSession(session: ExtensionSession) {\n    session.phase = 'stopped'\n\n    for (const module of this.modules.listByOwner(session.id)) {\n      this.modules.withdraw(session.id, session.extension.id, module.moduleId)\n      this.modules.unbind(session.id, session.extension.id, module.moduleId)\n    }\n    await this.cleanupExtensionSessionModules(session)\n    await session.subscriptions.dispose()\n    this.extensionSessionService.remove(session.id)\n  }\n\n  private getModuleOrThrow(moduleId: string) {\n    const module = this.modules.get(moduleId)\n    if (!module) {\n      throw new Error(`Module \\`${moduleId}\\` was not found.`)\n    }\n\n    return module\n  }\n\n  private assertKitAvailableForRuntime(kitId: string, runtime: PluginRuntime) {\n    const kit = this.kits.get(kitId)\n    if (!kit) {\n      throw new Error(`Kit \\`${kitId}\\` is not registered.`)\n    }\n\n    if (!kit.runtimes.includes(runtime)) {\n      throw new Error(`Kit \\`${kitId}\\` is not available for runtime \\`${runtime}\\`.`)\n    }\n\n    return kit\n  }\n","sourceCodeStart":544,"sourceCodeEnd":580,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/packages/plugin-sdk/src/plugin-host/core.ts#L544-L580","documentation":"Thrown by the private getModuleOrThrow() when no binding module exists for the given moduleId in the KitApiBindingRegistryService. It guards activateBinding, updateBinding, degradeBinding, and withdrawBinding, which all require a previously announced module to act upon.","triggerScenarios":"Calling host.activateBinding(sessionId, moduleId), updateBinding, degradeBinding, or withdrawBinding with a moduleId that was never announced via announceBinding/bindExtensionKitModule, or that was already unbound/withdrawn and removed.","commonSituations":"Passing the wrong moduleId (e.g. the kit id or extension id instead of the binding's module id). Operating on a module after session cleanup unbound it. Race between teardown and a pending binding operation.","solutions":["Use the moduleId returned by announceBinding/bindExtensionKitModule (the BindingRecord.moduleId), not the kit id or extension id.","Verify the module exists via host.getBinding(moduleId) or host.listBindings() before calling activate/update/degrade/withdraw.","Ensure binding operations are not issued after cleanupExtensionSession has run."],"exampleFix":"// before\nconst binding = host.announceBinding(sessionId, { kitId: 'kit.gamelet', ... })\nawait host.withdrawBinding(sessionId, 'kit.gamelet') // wrong: kit id used as moduleId\n\n// after\nawait host.withdrawBinding(sessionId, binding.moduleId)","handlingStrategy":"validation","validationCode":"const binding = host.getBinding(moduleId)\nif (!binding) {\n  throw new Error(`Module '${moduleId}' is not bound. Announce it first.`)\n}\nhost.activateBinding(sessionId, moduleId)","typeGuard":"function isModuleBound(host: ExtensionHost, moduleId: string): boolean {\n  return host.getBinding(moduleId) !== undefined\n}","tryCatchPattern":"try {\n  host.activateBinding(sessionId, moduleId)\n} catch (error) {\n  if (error instanceof Error && /was not found/.test(error.message)) {\n    // module was never announced or was unbound; re-announce or skip\n  } else {\n    throw error\n  }\n}","preventionTips":["Use the BindingRecord.moduleId returned by announceBinding for subsequent operations, not the kit id.","Verify via host.getBinding(moduleId) or host.listBindings() before activate/update/degrade/withdraw.","Avoid binding operations after cleanupExtensionSession has torn modules down."],"tags":["binding","module","not-found","lifecycle"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}