{"record":{"id":"e78fe1e0d799104b","repo":"deepseek-ai/deepseek-harness","slug":"the-image-data-is-not-canonical-base64","errorCode":null,"errorMessage":"the image data is not canonical base64","messagePattern":"the image data is not canonical base64","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mcp/mcp-client/src/tools.ts","lineNumber":384,"sourceCode":"}\n\n/** Narrow one JSON value to a string-keyed object. */\nfunction isRecord(value: JsonValue): value is { [key: string]: JsonValue } {\n  return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** Narrow a declared MIME string to the durable image vocabulary. */\nfunction isImageMediaType(value: string): value is ImageMediaType {\n  return IMAGE_MEDIA_TYPES.includes(value as ImageMediaType)\n}\n\n/** Decode one untrusted MCP image block without accepting base64 aliases. */\nfunction decodeImage(block: McpContentBlock): SaveImageAttachment {\n  if (block.mimeType === undefined || !isImageMediaType(block.mimeType)) {\n    throw new Error('the declared media type is not PNG, JPEG, WebP, or GIF')\n  }\n  if (block.data === undefined || !CANONICAL_BASE64.test(block.data)) {\n    throw new Error('the image data is not canonical base64')\n  }\n  const data = Buffer.from(block.data, 'base64')\n  if (data.toString('base64') !== block.data) {\n    throw new Error('the image data is not canonical base64')\n  }\n  return { data, mediaType: block.mimeType }\n}\n\n/**\n * Resolve the active model route and durable store for an image-bearing result.\n * @param ctx - plugin context with optional services.\n * @param exec - exact tool execution whose agent supplies the latest route.\n * @returns the attachment store after exact positive image-capability proof.\n */\nasync function resolveImageAdmission(ctx: Context, exec: ToolExecution): Promise<AttachmentStore> {\n  const attachments = ctx.get('attachments')\n  if (attachments === undefined) throw new Error('no attachment store is mounted')\n  const routed = exec.agent?.session.requestHeader()?.config","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/mcp/mcp-client/src/tools.ts#L366-L402","documentation":"Error \"the image data is not canonical base64\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/mcp/mcp-client/src/tools.ts:384 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-encode the image data as canonical base64."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}