crewAIInc/crewAI · error · ValueError
Invalid data_type: '{raw_data_type}'. Valid values are: 'fil
Error message
Invalid data_type: '{raw_data_type}'. Valid values are: 'file' (auto-detect), or one of: {', '.join(dt.value for dt in DataType)} What it means
ValueError raised while parsing the data_type argument passed to the RAG adapter's add-content API. String values are mapped through the DataType enum; the sentinel string 'file' means auto-detect and is skipped, and passing a DataType instance is accepted. Any other string that is not an enum value raises this error listing the valid options.
Source
Thrown at lib/crewai-tools/src/crewai_tools/adapters/crewai_rag_adapter.py:159
from crewai_tools.rag.base_loader import LoaderResult
from crewai_tools.rag.data_types import DataType, DataTypes
from crewai_tools.rag.source_content import SourceContent
documents: list[BaseRecord] = []
raw_data_type = kwargs.get("data_type")
base_metadata: dict[str, Any] = kwargs.get("metadata", {})
data_type: DataType | None = None
if raw_data_type is not None:
if isinstance(raw_data_type, DataType):
if raw_data_type != DataType.FILE:
data_type = raw_data_type
elif isinstance(raw_data_type, str):
if raw_data_type != "file":
try:
data_type = DataType(raw_data_type)
except ValueError:
raise ValueError(
f"Invalid data_type: '{raw_data_type}'. "
f"Valid values are: 'file' (auto-detect), or one of: "
f"{', '.join(dt.value for dt in DataType)}"
) from None
content_items: list[ContentItem] = list(args)
path_value = kwargs.get("path") or kwargs.get("file_path")
if path_value is not None:
content_items.append(path_value)
if url := kwargs.get("url"):
content_items.append(url)
if website := kwargs.get("website"):
content_items.append(website)
if github_url := kwargs.get("github_url"):
content_items.append(github_url)
if youtube_url := kwargs.get("youtube_url"):View on GitHub (pinned to 754d7323be)
Solutions
- Use the enum directly: from the data types module, pass DataType.PDF_FILE (or its exact string value) instead of guessing.
- Omit data_type entirely to use auto-detection from the content/extension.
- Print valid values once to discover exact names: [dt.value for dt in DataType].
Example fix
# before
adapter("report.pdf", data_type="pdf") # ValueError: Invalid data_type
# after
adapter("report.pdf", data_type=DataType.PDF_FILE)
# or simply omit for auto-detection:
adapter("report.pdf") Defensive patterns
Strategy: validation
Validate before calling
from crewai_tools.adapters.crewai_rag_adapter import DataType # adjust to real export
valid = {dt.value for dt in DataType}
if isinstance(data_type, str) and data_type != "file" and data_type not in valid:
raise ValueError(f"bad data_type {data_type!r}; choose from {sorted(valid)}") Type guard
def is_valid_data_type(value: object) -> bool:
if isinstance(value, DataType):
return True
return isinstance(value, str) and (value == "file" or value in {dt.value for dt in DataType}) Prevention
- Pass DataType enum members instead of strings.
- Omit data_type to use auto-detection for file inputs.
- Pin the crewai-tools version so enum values can't drift silently.
When it happens
Trigger: Calling the adapter with data_type='pdf_file' when the enum value is actually 'pdf_file' vs 'PDF_FILE' mismatch, or a typo like 'pdf', 'doc', 'csv_file', 'website' that is not a DataType member.
Common situations: Guessing type names instead of checking DataType values; version drift when enum member names changed between releases; passing 'file' variants like 'files' or 'auto'.
Related errors
- Directory does not exist: {source_ref}
- Client is not initialized
- File does not exist: {source_ref}
- Chunk overlap ({chunk_overlap}) cannot be >= chunk size ({ch
- No chunker defined for {self}
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/d22aebd7f5e4b80f.
Report an issue: GitHub.