{"record":{"id":"0783f15e318f18bb","repo":"paperclipai/paperclip","slug":"telegram-attachment-parser-contract-is-unavailable","errorCode":null,"errorMessage":"Telegram attachment parser contract is unavailable","messagePattern":"Telegram attachment parser contract is unavailable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/src/services/chat-sdk-runtime.ts","lineNumber":1494,"sourceCode":"      const parser = adapter as unknown as {\n        extractAttachments(raw: TelegramRawMessage): Attachment[];\n        parseTelegramMessage(\n          raw: TelegramRawMessage,\n          threadId: string,\n          content?: { text: string; formatted: Message[\"formatted\"] },\n        ): Message;\n        createAttachment(\n          type: Attachment[\"type\"],\n          fileId: string,\n          metadata: Record<string, unknown>,\n        ): Attachment;\n      };\n      if (\n        typeof parser.extractAttachments !== \"function\" ||\n        typeof parser.createAttachment !== \"function\" ||\n        typeof parser.parseTelegramMessage !== \"function\"\n      ) {\n        throw new Error(\"Telegram attachment parser contract is unavailable\");\n      }\n      const extractAttachments = parser.extractAttachments.bind(adapter);\n      const create = (\n        type: Attachment[\"type\"],\n        fileId: string,\n        metadata: Record<string, unknown>,\n      ) => parser.createAttachment(type, fileId, metadata);\n      parser.extractAttachments = (raw) =>\n        normalizeTelegramRichMessage(raw, create)?.attachments ??\n        normalizeTelegramMediaAttachments(\n          raw,\n          normalizeTelegramVideoNoteAttachments(raw, extractAttachments(raw)),\n          create,\n        );\n      const parseTelegramMessage = parser.parseTelegramMessage.bind(adapter);\n      parser.parseTelegramMessage = (raw, threadId, content) => {\n        const rich = normalizeTelegramRichMessage(raw, create);\n        if (!rich) return parseTelegramMessage(raw, threadId, content);","sourceCodeStart":1476,"sourceCodeEnd":1512,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/chat-sdk-runtime.ts#L1476-L1512","documentation":"The Telegram attachment path relies on the adapter exposing three functions: extractAttachments, createAttachment, and parseTelegramMessage. When the loaded parser object is missing any of these methods, the runtime throws this error because it cannot honor the Telegram attachment parser contract.","triggerScenarios":"Initializing/using the Telegram runtime where the adapter object's parser lacks extractAttachments, createAttachment, or parseTelegramMessage as functions.","commonSituations":"Downgraded or partially installed adapter package; adapter version drift where parser methods were renamed/removed; custom adapter builds missing the attachment parser module; dependency resolution pulling a stub implementation.","solutions":["Reinstall/upgrade the Telegram adapter package so the full parser surface (extractAttachments, createAttachment, parseTelegramMessage) is present.","Check the adapter version against the runtime's expectations; pin a compatible version.","If using a custom adapter, implement all three parser methods with the expected signatures.","Log the parser object at startup and assert the three methods exist as part of a smoke test."],"exampleFix":"// before\nconst parser = require(\"telegram-adapter-lite\").parser; // missing parseTelegramMessage\n// after\nconst parser = require(\"@paperclipai/telegram-adapter\").parser;\nfor (const m of [\"extractAttachments\", \"createAttachment\", \"parseTelegramMessage\"] as const) {\n  if (typeof parser[m] !== \"function\") throw new Error(`parser missing ${m}`);\n}","handlingStrategy":"type-guard","validationCode":"function hasTelegramParser(p: unknown): p is { extractAttachments: Function; createAttachment: Function; parseTelegramMessage: Function } {\n  return typeof p === \"object\" && p !== null &&\n    [\"extractAttachments\", \"createAttachment\", \"parseTelegramMessage\"].every(\n      (m) => typeof (p as any)[m] === \"function\");\n}","typeGuard":"function hasTelegramParser(p: unknown): p is { extractAttachments: Function; createAttachment: Function; parseTelegramMessage: Function } {\n  return typeof p === \"object\" && p !== null &&\n    typeof (p as any).extractAttachments === \"function\" &&\n    typeof (p as any).createAttachment === \"function\" &&\n    typeof (p as any).parseTelegramMessage === \"function\";\n}","tryCatchPattern":"try {\n  await telegramRuntime.start();\n} catch (err) {\n  if (/parser contract/.test(String(err?.message))) {\n    logger.error(\"Telegram adapter missing attachment parser; reinstall/upgrade the adapter package\");\n  }\n  throw err;\n}","preventionTips":["Pin the adapter package version; reinstall on version drift.","Add a startup assertion that the parser surface is complete.","Avoid custom adapter forks that omit parser methods."],"tags":["telegram","adapter","contract"],"backgroundTag":"missing-dependency","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}