{"record":{"id":"94e873bace9fc70d","repo":"crewAIInc/crewAI","slug":"bedrock-does-not-support-url-references-resolve","errorCode":null,"errorMessage":"Bedrock does not support URL references - resolve to bytes first","messagePattern":"Bedrock does not support URL references - resolve to bytes first","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-files/src/crewai_files/formatting/bedrock.py","lineNumber":83,"sourceCode":"        Returns:\n            Content block dict or None if not supported.\n        \"\"\"\n        content_type = file.content_type\n\n        if isinstance(resolved, FileReference):\n            if not resolved.file_uri:\n                raise ValueError(\"Bedrock requires file_uri for FileReference (S3 URI)\")\n            return self._format_s3_block(content_type, resolved.file_uri, name)\n\n        if isinstance(resolved, InlineBytes):\n            return self._format_bytes_block(content_type, resolved.data, name)\n\n        if isinstance(resolved, InlineBase64):\n            file_bytes = base64.b64decode(resolved.data)\n            return self._format_bytes_block(content_type, file_bytes, name)\n\n        if isinstance(resolved, UrlReference):\n            raise ValueError(\n                \"Bedrock does not support URL references - resolve to bytes first\"\n            )\n\n        raise TypeError(f\"Unexpected resolved type: {type(resolved).__name__}\")\n\n    def _format_s3_block(\n        self,\n        content_type: str,\n        file_uri: str,\n        name: str | None,\n    ) -> dict[str, Any] | None:\n        \"\"\"Format block with S3 location source.\n\n        Args:\n            content_type: MIME type.\n            file_uri: S3 URI.\n            name: File name for documents.\n","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-files/src/crewai_files/formatting/bedrock.py#L65-L101","documentation":"The Bedrock formatter raises ValueError('Bedrock does not support URL references - resolve to bytes first') when the resolved file is a UrlReference. The Bedrock Converse API only accepts inline bytes or S3 locations; it cannot fetch arbitrary public URLs, so the library refuses UrlReference rather than sending a request Bedrock would reject.","triggerScenarios":"Attaching a file by URL (UrlReference with url=\"https://...\") to a crew whose LLM is a Bedrock model; a resolver configured to keep remote files as URL references (no download) combined with BedrockFormatting.","commonSituations":"User pastes a public https URL for an image/PDF and assumes every provider can read it; a pipeline shared across OpenAI (which accepts URLs) and Bedrock agents; resolvers upgraded to lazily pass URLs through to avoid downloading.","solutions":["Resolve/download the URL to bytes before formatting: use a resolver mode that produces InlineBytes/InlineBase64 instead of UrlReference.","Or download the file to S3 and pass FileReference(file_uri=\"s3://...\") which Bedrock supports.","In a shared pipeline, branch on the target provider: keep UrlReference for OpenAI-style providers, force byte resolution for Bedrock.","Pre-fetch the URL yourself (requests.get(...).content) and attach the raw bytes."],"exampleFix":"# before\nresolved = UrlReference(url=\"https://example.com/doc.pdf\", content_type=\"application/pdf\")\nblock = bedrock_formatter.format_block(resolved)  # raises\n\n# after\nimport requests\nresp = requests.get(\"https://example.com/doc.pdf\", timeout=30)\nresolved = InlineBytes(data=resp.content, content_type=\"application/pdf\")\nblock = bedrock_formatter.format_block(resolved)","handlingStrategy":"fallback","validationCode":"if isinstance(resolved, UrlReference) and provider_uses_bedrock:\n    resolved = InlineBytes(data=fetch(resolved.url), content_type=resolved.content_type)","typeGuard":"def needs_resolution_for_bedrock(resolved: ResolvedFileType) -> bool:\n    return isinstance(resolved, UrlReference)","tryCatchPattern":"try:\n    block = bedrock_formatter.format_block(resolved)\nexcept ValueError as e:\n    if \"URL references\" in str(e) and isinstance(resolved, UrlReference):\n        data = requests.get(resolved.url, timeout=30).content\n        block = bedrock_formatter.format_block(InlineBytes(data=data, content_type=resolved.content_type))\n    else:\n        raise","preventionTips":["Configure the resolver to download remote files to bytes when Bedrock is the target.","Keep a per-provider capability map: Bedrock = {InlineBytes, InlineBase64, FileReference(s3)} only.","Never attach raw https URLs to Bedrock tasks."],"tags":["bedrock","url","resolver","formatter","bytes"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}