{"record":{"id":"851d1f6496d71e6d","repo":"infiniflow/ragflow","slug":"format-invalid","errorCode":"format_invalid","errorMessage":"`chunk_method` {chunk_method} doesn't exist","messagePattern":"`chunk_method` (.+?) doesn't exist","errorType":"validation","errorClass":"PydanticCustomError","httpStatus":null,"severity":"error","filePath":"api/utils/validation_utils.py","lineNumber":538,"sourceCode":"    name: Annotated[str | None, Field(default=None, max_length=65535)]\n    chunk_method: Annotated[str | None, Field(default=None, max_length=65535)]\n    pipeline_id: Annotated[str | None, Field(default=None, max_length=65535)]\n    enabled: Annotated[int | None, Field(default=None, ge=0, le=1)]\n    chunk_count: Annotated[int | None, Field(default=None, ge=0)]\n    token_count: Annotated[int | None, Field(default=None, ge=0)]\n    progress: Annotated[float | None, Field(default=None, ge=0.0, le=1.0)]\n    parser_config: Annotated[ParserConfig | None, Field(default=None)]\n    meta_fields: Annotated[dict | None, Field(default={})]\n\n    @field_validator(\"chunk_method\", mode=\"after\")\n    @classmethod\n    def validate_document_chunk_method(cls, chunk_method: str | None):\n        \"\"\"Validate an optional document parser method.\"\"\"\n        if chunk_method:\n            # Validate chunk method if present\n            valid_chunk_method = {\"naive\", \"manual\", \"qa\", \"table\", \"paper\", \"book\", \"laws\", \"presentation\", \"picture\", \"one\", \"knowledge_graph\", \"email\", \"tag\"}\n            if chunk_method not in valid_chunk_method:\n                raise PydanticCustomError(\"format_invalid\", \"`chunk_method` {chunk_method} doesn't exist\", {\"chunk_method\": chunk_method})\n\n        return chunk_method\n\n    @field_validator(\"enabled\", mode=\"after\")\n    @classmethod\n    def validate_document_enabled(cls, enabled: str | None):\n        \"\"\"Validate the optional enabled flag.\"\"\"\n        if enabled:\n            converted = int(enabled)\n            if converted < 0 or converted > 1:\n                raise PydanticCustomError(\"format_invalid\", \"`enabled` value invalid, only accept 0 or 1 but is {enabled}\", {\"enabled\": enabled})\n\n        return enabled\n\n    @field_validator(\"meta_fields\", mode=\"after\")\n    @classmethod\n    def validate_document_meta_fields(cls, meta_fields: dict | None):\n        \"\"\"Validate user-provided document metadata values.\"\"\"","sourceCodeStart":520,"sourceCodeEnd":556,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/utils/validation_utils.py#L520-L556","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"# before\n{\"chunk_method\": \"naiive\"}\n\n# after\n{\"chunk_method\": \"naive\"}","handlingStrategy":"validation","validationCode":"DOC_CHUNK_METHODS = {\"naive\",\"manual\",\"qa\",\"table\",\"paper\",\"book\",\"laws\",\"presentation\",\"picture\",\"one\",\"knowledge_graph\",\"email\",\"tag\"}\n\nif chunk_method and chunk_method not in DOC_CHUNK_METHODS:\n    raise ValueError(f\"unsupported document chunk_method: {chunk_method}\")","typeGuard":"const DOC_CHUNK_METHODS = new Set([\"naive\",\"manual\",\"qa\",\"table\",\"paper\",\"book\",\"laws\",\"presentation\",\"picture\",\"one\",\"knowledge_graph\",\"email\",\"tag\"]);\nconst isDocChunkMethod = (v: string): v is string => DOC_CHUNK_METHODS.has(v);","tryCatchPattern":"try:\n    api.update_documents(doc)\nexcept ValidationError as e:\n    if any(err[\"type\"] == \"format_invalid\" and \"chunk_method\" in str(err) for err in e.errors()):\n        prompt_user_to_pick_chunk_method()","preventionTips":["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."],"tags":["chunking","validation","pydantic","documents"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}