{"record":{"id":"dd26f19fe21816a6","repo":"langchain-ai/deepagents","slug":"could-not-parse-embedded-resource-block-block-exp","errorCode":null,"errorMessage":"Could not parse embedded resource block. Block expected either a `text` or `blob` property.","messagePattern":"Could not parse embedded resource block\\. Block expected either a `text` or `blob` property\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/acp/deepagents_acp/utils.py","lineNumber":99,"sourceCode":"    \"\"\"\n    resource = block.resource\n    if hasattr(resource, \"text\"):\n        mime_type = getattr(resource, \"mime_type\", \"application/text\")\n        return [{\"type\": \"text\", \"text\": f\"[Embedded {mime_type} resource: {resource.text}\"}]\n    if hasattr(resource, \"blob\"):\n        mime_type = getattr(resource, \"mime_type\", \"application/octet-stream\")\n        data_uri = f\"data:{mime_type};base64,{resource.blob}\"\n        return [\n            {\n                \"type\": \"text\",\n                \"text\": f\"[Embedded resource: {data_uri}]\",\n            }\n        ]\n    msg = (\n        \"Could not parse embedded resource block. \"\n        \"Block expected either a `text` or `blob` property.\"\n    )\n    raise ValueError(msg)\n\n\nDANGEROUS_SHELL_PATTERNS = (\n    \"$(\",  # Command substitution\n    \"`\",  # Backtick command substitution\n    \"$'\",  # ANSI-C quoting (can encode dangerous chars via escape sequences)\n    \"\\n\",  # Newline (command injection)\n    \"\\r\",  # Carriage return (command injection)\n    \"\\t\",  # Tab (can be used for injection in some shells)\n    \"<(\",  # Process substitution (input)\n    \">(\",  # Process substitution (output)\n    \"<<<\",  # Here-string\n    \"<<\",  # Here-doc (can embed commands)\n    \">>\",  # Append redirect\n    \">\",  # Output redirect\n    \"<\",  # Input redirect\n    \"${\",  # Variable expansion with braces (can run commands via ${var:-$(cmd)})\n)","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/acp/deepagents_acp/utils.py#L81-L117","documentation":"`convert_embedded_resource_block_to_content_blocks` raises ValueError when an ACP `EmbeddedResourceContentBlock`'s inner `resource` contains neither a `text` nor a `blob` property, so the block cannot be mapped to a LangChain content block. The spec requires one of the two; a block missing both is malformed.","triggerScenarios":"Calling `prompt()` with an embedded resource whose `resource` object has no `text` and no `blob` key (e.g. only a `uri`, or a typo'd key like `body`/`data`) — conversion is invoked at server.py:989-990.","commonSituations":"A hand-built or buggy MCP/ACP client serializing resources with wrong field names; an intermediary proxy stripping `text`/`blob` fields; protocol-version drift where a client emits a resource shape the server doesn't recognize.","solutions":["Ensure the embedded resource includes either `text` (for textual content) or `blob` (base64 for binary) before sending the prompt","Fix or update the client library producing the resource block so it conforms to the ACP/MCP EmbeddedResource schema","Log the raw block (it is included in the error context) and check for typos in field names","Convert the resource yourself into a TextContentBlock if you control the prompt construction"],"exampleFix":"// before\n{\"type\": \"resource_link\", \"resource\": {\"uri\": \"file:///a.txt\"}}\n// after\n{\"type\": \"resource_link\", \"resource\": {\"uri\": \"file:///a.txt\", \"text\": \"file contents\"}}","handlingStrategy":"validation","validationCode":"resource = block.resource\nif not (\"text\" in resource or \"blob\" in resource):\n    raise ValueError(f\"embedded resource {resource.get('uri')!r} needs 'text' or 'blob'\")","typeGuard":"def has_resource_payload(resource: dict) -> bool:\n    return isinstance(resource, dict) and (\"text\" in resource or \"blob\" in resource)","tryCatchPattern":"try:\n    resp = await conn.prompt(blocks, session_id)\nexcept ValueError as exc:\n    if \"embedded resource block\" in str(exc):\n        # drop/replace the malformed block and retry\n        ...\n    raise","preventionTips":["Validate embedded resources against the ACP/MCP EmbeddedResource schema before sending","Ensure binary resources are base64-encoded in `blob`, textual ones in `text`","Check field-name spelling when constructing resource dicts by hand","Keep client and server ACP protocol versions in sync"],"tags":["acp","embedded-resource","validation","schema","valueerror"],"backgroundTag":"schema-validation-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}