infiniflow/ragflow · error · PydanticCustomError
format_invalid
format_invalid
Error message
`chunk_method` {chunk_method} doesn't exist What it means
Document-level validator (on the document update/create request model) that rejects a chunk_method string outside the fixed vocabulary {naive, manual, qa, table, paper, book, laws, presentation, picture, one, knowledge_graph, email, tag}. It only runs when chunk_method is truthy on the document request, and raises format_invalid with the offending value interpolated.
Source
Thrown at api/utils/validation_utils.py:538
name: Annotated[str | None, Field(default=None, max_length=65535)]
chunk_method: Annotated[str | None, Field(default=None, max_length=65535)]
pipeline_id: Annotated[str | None, Field(default=None, max_length=65535)]
enabled: Annotated[int | None, Field(default=None, ge=0, le=1)]
chunk_count: Annotated[int | None, Field(default=None, ge=0)]
token_count: Annotated[int | None, Field(default=None, ge=0)]
progress: Annotated[float | None, Field(default=None, ge=0.0, le=1.0)]
parser_config: Annotated[ParserConfig | None, Field(default=None)]
meta_fields: Annotated[dict | None, Field(default={})]
@field_validator("chunk_method", mode="after")
@classmethod
def validate_document_chunk_method(cls, chunk_method: str | None):
"""Validate an optional document parser method."""
if chunk_method:
# Validate chunk method if present
valid_chunk_method = {"naive", "manual", "qa", "table", "paper", "book", "laws", "presentation", "picture", "one", "knowledge_graph", "email", "tag"}
if chunk_method not in valid_chunk_method:
raise PydanticCustomError("format_invalid", "`chunk_method` {chunk_method} doesn't exist", {"chunk_method": chunk_method})
return chunk_method
@field_validator("enabled", mode="after")
@classmethod
def validate_document_enabled(cls, enabled: str | None):
"""Validate the optional enabled flag."""
if enabled:
converted = int(enabled)
if converted < 0 or converted > 1:
raise PydanticCustomError("format_invalid", "`enabled` value invalid, only accept 0 or 1 but is {enabled}", {"enabled": enabled})
return enabled
@field_validator("meta_fields", mode="after")
@classmethod
def validate_document_meta_fields(cls, meta_fields: dict | None):
"""Validate user-provided document metadata values."""View on GitHub (pinned to 554fb1133a)
Solutions
- Use one of the allowed values exactly as listed in the validator: naive, manual, qa, table, paper, book, laws, presentation, picture, one, knowledge_graph, email, tag.
- If you intended 'resume' chunking, set it at the dataset level (CreateDatasetReq), not through this document-level field.
- Check the running RAGFlow version's validator set — the accepted vocabulary is hardcoded and can differ between releases.
Example fix
# before
{"chunk_method": "naiive"}
# after
{"chunk_method": "naive"} Defensive patterns
Strategy: validation
Validate before calling
DOC_CHUNK_METHODS = {"naive","manual","qa","table","paper","book","laws","presentation","picture","one","knowledge_graph","email","tag"}
if chunk_method and chunk_method not in DOC_CHUNK_METHODS:
raise ValueError(f"unsupported document chunk_method: {chunk_method}") Type guard
const DOC_CHUNK_METHODS = new Set(["naive","manual","qa","table","paper","book","laws","presentation","picture","one","knowledge_graph","email","tag"]); const isDocChunkMethod = (v: string): v is string => DOC_CHUNK_METHODS.has(v);
Try / catch
try:
api.update_documents(doc)
except ValidationError as e:
if any(err["type"] == "format_invalid" and "chunk_method" in str(err) for err in e.errors()):
prompt_user_to_pick_chunk_method() Prevention
- Drive the chunk_method dropdown from a constant list mirrored from the validator.
- Do not reuse the dataset-level enum for document updates (resume vs knowledge_graph differ).
- Pin the client to a RAGFlow version and re-check enums on upgrade.
When it happens
Trigger: PUT /api/v1/datasets/{id}/documents with body {"chunk_method": "audio"} or "resume" or a typo like "naiive"; note this document-level set differs from the dataset-level set (which includes resume but not knowledge_graph).
Common situations: Reusing the dataset-level chunk_method list for document updates (resume is valid at dataset level but not in this validator's set); new parser names added in a newer RAGFlow version but the client targets an older API; frontend dropdown populated from a different endpoint's enum.
Related errors
- invalid_uuid_format
- literal_error
- duplicate_uuids
- At least one of dest_file_id or new_name must be provided
- new_name can only be used with a single file
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/851d1f6496d71e6d.
Report an issue: GitHub.