{"record":{"id":"e8067aeee375f1a7","repo":"moeru-ai/airi","slug":"unknown-plugin-transport-kind","errorCode":null,"errorMessage":"Unknown plugin transport kind.","messagePattern":"Unknown plugin transport kind\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugin-sdk/src/plugin-host/runtimes/node/index.ts","lineNumber":37,"sourceCode":" * - `transport` describes a transport supported by the node runtime\n *\n * Returns:\n * - A node-compatible Eventa context, or throws if the transport is not implemented\n */\nexport function createPluginContext(transport: PluginTransport): EventContext<any, any> {\n  switch (transport.kind) {\n    case 'in-memory':\n      return createContext()\n    case 'websocket':\n      throw new Error('WebSocket transport is not implemented for node runtime yet.')\n    case 'node-worker':\n      throw new Error('Node worker transport is not implemented yet.')\n    case 'electron':\n      throw new Error('Electron transport is not implemented yet.')\n    case 'web-worker':\n      throw new Error('Web worker transport is not available in node runtime.')\n    default:\n      throw new Error('Unknown plugin transport kind.')\n  }\n}\n","sourceCodeStart":19,"sourceCodeEnd":40,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/plugin-sdk/src/plugin-host/runtimes/node/index.ts#L19-L40","documentation":"Thrown by createPluginContext in the node runtime when transport.kind matches none of the known cases. The PluginTransport union covers in-memory, websocket, node-worker, electron, and web-worker; reaching default means the value is outside that union — typically a malformed object, an undefined kind, or a newer kind string passed to an older SDK version.","triggerScenarios":"Passing { kind: undefined } or {} because the transport was built from unvalidated JSON/env config; a typo like 'inmemory' or 'in_memory'; a newer plugin-sdk peer passing a kind this host version does not know; spreading an object that lost the kind field.","commonSituations":"Transport chosen from environment variables or user config without validation; mixed plugin-sdk versions in a monorepo; refactoring that renames the discriminant field; serialization dropping the kind property.","solutions":["Log/inspect the actual transport object and fix the kind value to a literal member of the union ('in-memory' for node).","Validate config-derived transports with a literal allowlist before calling createPluginContext.","Align plugin-sdk versions across the workspace so both sides agree on the set of kinds.","If you are extending PluginTransport with a new kind, add the case to the runtime switch instead of relying on default."],"exampleFix":"// before\nconst ctx = createPluginContext(JSON.parse(process.env.PLUGIN_TRANSPORT!)) // { \"kind\": \"inmemory\" } -> default throw\n\n// after\nconst KINDS = ['in-memory', 'websocket', 'node-worker', 'electron', 'web-worker'] as const\nconst raw = JSON.parse(process.env.PLUGIN_TRANSPORT!) as { kind?: string }\nif (!KINDS.includes(raw.kind ?? '')) throw new Error(`Bad PLUGIN_TRANSPORT.kind: ${raw.kind}`)\nconst ctx = createPluginContext({ kind: 'in-memory' })","handlingStrategy":"validation","validationCode":"const KINDS = ['in-memory', 'websocket', 'node-worker', 'electron', 'web-worker'] as const\ntype KnownKind = typeof KINDS[number]\nfunction parseTransport(raw: unknown): PluginTransport {\n  const kind = (raw as { kind?: unknown })?.kind\n  if (typeof kind !== 'string' || !(KINDS as readonly string[]).includes(kind)) {\n    throw new Error(`Invalid transport kind: ${String(kind)}`)\n  }\n  return raw as PluginTransport\n}","typeGuard":"const KNOWN_KINDS = ['in-memory', 'websocket', 'node-worker', 'electron', 'web-worker'] as const\nconst isKnownTransportKind = (value: unknown): value is (typeof KNOWN_KINDS)[number] =>\n  typeof value === 'string' && (KNOWN_KINDS as readonly string[]).includes(value)","tryCatchPattern":"try {\n  ctx = createPluginContext(transport)\n} catch (error) {\n  if (error instanceof Error && error.message === 'Unknown plugin transport kind.') {\n    // log the offending object and fix config; do not retry blindly\n    console.error('transport =', transport)\n  }\n  throw error\n}","preventionTips":["Never pass unvalidated JSON/env data as PluginTransport; validate the discriminant first.","Pin one plugin-sdk version across host and plugins to keep the kind union in sync.","Log the full transport object when validation fails to catch lost/renamed fields."],"tags":["plugin-sdk","transport","discriminated-union","invalid-config"],"backgroundTag":"unsupported-transport-kind","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}