crewAIInc/crewAI · error · ValueError
Bedrock does not support URL references - resolve to bytes f
Error message
Bedrock does not support URL references - resolve to bytes first
What it means
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.
Source
Thrown at lib/crewai-files/src/crewai_files/formatting/bedrock.py:83
Returns:
Content block dict or None if not supported.
"""
content_type = file.content_type
if isinstance(resolved, FileReference):
if not resolved.file_uri:
raise ValueError("Bedrock requires file_uri for FileReference (S3 URI)")
return self._format_s3_block(content_type, resolved.file_uri, name)
if isinstance(resolved, InlineBytes):
return self._format_bytes_block(content_type, resolved.data, name)
if isinstance(resolved, InlineBase64):
file_bytes = base64.b64decode(resolved.data)
return self._format_bytes_block(content_type, file_bytes, name)
if isinstance(resolved, UrlReference):
raise ValueError(
"Bedrock does not support URL references - resolve to bytes first"
)
raise TypeError(f"Unexpected resolved type: {type(resolved).__name__}")
def _format_s3_block(
self,
content_type: str,
file_uri: str,
name: str | None,
) -> dict[str, Any] | None:
"""Format block with S3 location source.
Args:
content_type: MIME type.
file_uri: S3 URI.
name: File name for documents.
View on GitHub (pinned to 754d7323be)
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.
Example fix
# before
resolved = UrlReference(url="https://example.com/doc.pdf", content_type="application/pdf")
block = bedrock_formatter.format_block(resolved) # raises
# after
import requests
resp = requests.get("https://example.com/doc.pdf", timeout=30)
resolved = InlineBytes(data=resp.content, content_type="application/pdf")
block = bedrock_formatter.format_block(resolved) Defensive patterns
Strategy: fallback
Validate before calling
if isinstance(resolved, UrlReference) and provider_uses_bedrock:
resolved = InlineBytes(data=fetch(resolved.url), content_type=resolved.content_type) Type guard
def needs_resolution_for_bedrock(resolved: ResolvedFileType) -> bool:
return isinstance(resolved, UrlReference) Try / catch
try:
block = bedrock_formatter.format_block(resolved)
except ValueError as e:
if "URL references" in str(e) and isinstance(resolved, UrlReference):
data = requests.get(resolved.url, timeout=30).content
block = bedrock_formatter.format_block(InlineBytes(data=data, content_type=resolved.content_type))
else:
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Bedrock requires file_uri for FileReference (S3 URI)
- URL scheme must be 'http' or 'https'
- Invalid URL scheme: {self.url}
- Gemini requires file_uri for FileReference
- Unsupported content type for Responses API: {content_type}
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/94e873bace9fc70d.
Report an issue: GitHub.