{"record":{"id":"730a5866029d919a","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"no-adapter-found-for-protocol-metadata-protocol","errorCode":null,"errorMessage":"No adapter found for protocol \"${metadata.protocol}\"","messagePattern":"No adapter found for protocol \"(.+?)\"","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"MemoryProxy/src/injection/pipeline.ts","lineNumber":93,"sourceCode":"   *\n   * @param body Raw request body (protocol-specific format)\n   * @param metadata Request metadata\n   * @returns Modified request body with injected content\n   */\n  async process(\n    body: Record<string, unknown>,\n    metadata: AgentContextMetadata,\n  ): Promise<Record<string, unknown>> {\n    const pipelineStartMs = Date.now();\n\n    // ── Observer: pipeline start ─────────────────────────────────────────\n    safeCall(() => this.observer.onPipelineStart(metadata));\n\n    try {\n      // 1. Get the appropriate adapter\n      const adapter = this.adapters.get(metadata.protocol);\n      if (!adapter) {\n        throw new Error(\n          `No adapter found for protocol \"${metadata.protocol}\"`,\n        );\n      }\n\n      // 2. Parse → AgentContext\n      const ctx: AgentContext = adapter.parse(body, metadata);\n\n      // 2.5 Detect the agent profile.\n      //     Priority: ① agentProfiles lookup by metadata.agentSource (URL path prefix),\n      //               ② legacy detectAgent (system prompt content scanning, for un-prefixed paths).\n      //     A matching Profile enables precise anchor landing; otherwise hooks fall\n      //     back to coarse-grained `point` behavior.\n      {\n        let profile: AgentProfile | null = null;\n\n        // ① Fast path: URL-path-based lookup (zero cost, no string scanning)\n        if (this.agentProfiles) {\n          profile = this.agentProfiles.get(metadata.agentSource) ?? null;","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/MemoryProxy/src/injection/pipeline.ts#L75-L111","documentation":"The injection pipeline maps a request's metadata.protocol (e.g. openai, anthropic) to a registered adapter via this.adapters.get(). When no adapter is registered for that protocol key, process throws immediately before parsing. This prevents unrecognized request formats from entering the pipeline.","triggerScenarios":"Calling pipeline.process(body, metadata) where metadata.protocol is a string not present in the adapters map — e.g. typo'd protocol name, a new protocol used before registerAdapter, or protocol omitted/undefined.","commonSituations":"Clients pointing the proxy at an unsupported API surface (e.g. sending gemini-style payloads to an openai-only proxy); after upgrading the library, protocol key renamed (e.g. 'openai' -> 'openai-compat'); custom adapters not registered during bootstrap.","solutions":["Check the protocol value in the failing request and compare with the keys registered via pipeline.registerAdapter / the adapters map","Fix the client/SDK configuration so it uses a supported protocol string","Register an adapter for the protocol before processing requests","Add startup validation that logs registered protocols to catch key mismatches early"],"exampleFix":"// before\npipeline.process(body, { protocol: \"openai-chat\" });\n// after\npipeline.process(body, { protocol: \"openai\" }); // matches registered adapter key","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set(pipeline.adapters.keys());\nif (!SUPPORTED.has(metadata.protocol)) {\n  throw new Error(`protocol '${metadata.protocol}' not supported; use one of: ${[...SUPPORTED].join(\", \")}`);\n}","typeGuard":"function hasAdapter(pipeline: Pipeline, protocol: string): boolean {\n  return pipeline.adapters.has(protocol);\n}","tryCatchPattern":null,"preventionTips":["Centralize the protocol constant instead of hardcoding strings at call sites","Register all adapters during bootstrap and assert registration in tests","Validate protocol at the edge (route handler) before entering the pipeline","Log the list of registered protocols on startup"],"tags":["adapter","protocol","configuration","pipeline"],"backgroundTag":"no-adapter-for-protocol","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}