{"record":{"id":"21d6501d5cdc06c8","repo":"ruvnet/ruflo","slug":"http-transport-requires-host-and-port-configuratio","errorCode":null,"errorMessage":"HTTP transport requires host and port configuration","messagePattern":"HTTP transport requires host and port configuration","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/mcp/src/transport/index.ts","lineNumber":42,"sourceCode":"\nexport type TransportConfig =\n  | { type: 'stdio' } & StdioTransportConfig\n  | { type: 'http' } & HttpTransportConfig\n  | { type: 'websocket' } & WebSocketTransportConfig\n  | { type: 'in-process' };\n\nexport function createTransport(\n  type: TransportType,\n  logger: ILogger,\n  config?: Partial<TransportConfig>\n): ITransport {\n  switch (type) {\n    case 'stdio':\n      return createStdioTransport(logger, config as StdioTransportConfig);\n\n    case 'http':\n      if (!config || !('host' in config) || !('port' in config)) {\n        throw new Error('HTTP transport requires host and port configuration');\n      }\n      return createHttpTransport(logger, {\n        host: config.host as string,\n        port: config.port as number,\n        ...config,\n      } as HttpTransportConfig);\n\n    case 'websocket':\n      if (!config || !('host' in config) || !('port' in config)) {\n        throw new Error('WebSocket transport requires host and port configuration');\n      }\n      return createWebSocketTransport(logger, {\n        host: config.host as string,\n        port: config.port as number,\n        ...config,\n      } as WebSocketTransportConfig);\n\n    case 'in-process':","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/mcp/src/transport/index.ts#L24-L60","documentation":"createTransport('http', logger, config) requires the config object to contain host and port keys; the factory checks key presence ('host' in config / 'port' in config) before delegating to createHttpTransport and throws this error when either is missing. It is a fail-fast guard so the HTTP listener never binds with an undefined address. Note it checks presence, not truthiness — { host: '', port: 0 } passes.","triggerScenarios":"Calling createTransport('http', logger) with no config; passing a config built from env vars where HOST/PORT are unset so the keys are absent; passing a StdioTransportConfig-shaped object or a Partial<TransportConfig> that lacks host/port into the http branch.","commonSituations":"Config loaded from .env that is missing in CI; one shared config object reused across transport types; code upgraded from a version where http transport defaulted host/port.","solutions":["Pass explicit values: createTransport('http', logger, { host: '127.0.0.1', port: 3000 })","Default env-derived values: host: process.env.HOST ?? '127.0.0.1', port: Number(process.env.PORT ?? 3000)","Call createHttpTransport(logger, cfg) directly so TypeScript enforces HttpTransportConfig"],"exampleFix":"// before\nconst t = createTransport('http', logger, { host: process.env.HOST } as any);\n\n// after\nconst t = createTransport('http', logger, {\n  host: process.env.HOST ?? '127.0.0.1',\n  port: Number(process.env.PORT ?? 3000),\n});","handlingStrategy":"validation","validationCode":"const httpCfg = {\n  host: process.env.HOST ?? '127.0.0.1',\n  port: Number(process.env.PORT ?? 3000),\n};\nif (!('host' in httpCfg) || !('port' in httpCfg)) {\n  throw new Error('HTTP transport config incomplete');\n}\nconst t = createTransport('http', logger, httpCfg);","typeGuard":"function isHttpConfig(c: unknown): c is { host: string; port: number } {\n  return (\n    !!c && typeof c === 'object' &&\n    'host' in c && typeof (c as { host: unknown }).host === 'string' &&\n    'port' in c && typeof (c as { port: unknown }).port === 'number'\n  );\n}","tryCatchPattern":null,"preventionTips":["Validate config at boot with a schema (e.g. zod) that requires host/port for http","Default env-derived values instead of passing possibly-absent keys","Remember the library checks key presence only - empty strings and 0 still pass, so validate values yourself"],"tags":["transport","http","configuration","factory"],"backgroundTag":"missing-configuration","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}