{"record":{"id":"8c01ef5f3d0d4d57","repo":"infiniflow/ragflow","slug":"string-too-long","errorCode":"string_too_long","errorMessage":"Parser config exceeds size limit (max 65,535 characters). Current size: {actual}","messagePattern":"Parser config exceeds size limit \\(max 65,535 characters\\)\\. Current size: (.+?)","errorType":"validation","errorClass":"PydanticCustomError","httpStatus":null,"severity":"error","filePath":"api/utils/validation_utils.py","lineNumber":756,"sourceCode":"        Implements a two-stage validation workflow:\n        1. Null check - bypass validation for empty configurations\n        2. Model serialization - convert Pydantic model to JSON string\n        3. Size verification - enforce maximum allowed payload size\n\n        Args:\n            v (ParserConfig | None): Raw parser configuration object\n\n        Returns:\n            ParserConfig | None: Validated configuration object\n\n        Raises:\n            PydanticCustomError: When serialized JSON exceeds 65,535 characters\n        \"\"\"\n        if v is None:\n            return None\n\n        if (json_str := v.model_dump_json()) and len(json_str) > 65535:\n            raise PydanticCustomError(\"string_too_long\", \"Parser config exceeds size limit (max 65,535 characters). Current size: {actual}\", {\"actual\": len(json_str)})\n        return v\n\n    @field_validator(\"pipeline_id\", mode=\"after\")\n    @classmethod\n    def validate_pipeline_id(cls, v: str | None) -> str | None:\n        \"\"\"Validate pipeline_id as 32-char lowercase hex string if provided.\n\n        Rules:\n        - None or empty string: treat as None (not set)\n        - Must be exactly length 32\n        - Must contain only hex digits (0-9a-fA-F); normalized to lowercase\n        \"\"\"\n        if v is None:\n            return None\n        if v == \"\":\n            return None\n        if len(v) != 32:\n            raise PydanticCustomError(\"format_invalid\", \"pipeline_id must be 32 hex characters\")","sourceCodeStart":738,"sourceCodeEnd":774,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/utils/validation_utils.py#L738-L774","documentation":"Validator that serializes parser_config to JSON and enforces the 65,535-character budget (matching the DB column limit for the config blob). If model_dump_json() produces more than 65,535 characters it raises string_too_long with the actual size. This guards against truncation or insert failures deeper in the storage layer.","triggerScenarios":"POST/PUT dataset with a parser_config containing huge values — e.g. a very long 'raptor' prompt, thousands of page ranges, or an embedded knowledge graph instruction block — whose serialized JSON exceeds 64 KiB.","commonSituations":"Custom LLM prompts for RAPTOR/GraphRAKER pasted into parser_config.raptor.prompt; auto-generated configs with unbounded lists; config templates inherited from another system with large embedded stopwords/dictionaries.","solutions":["Trim the oversized value — usually the raptor prompt or a page-range/manual chunk list — until the serialized config is under 65,535 chars.","Compute json.dumps(config, separators=(',',':')) length client-side before sending to fail fast.","Move large prompts into the model/LLM configuration layer rather than embedding them in parser_config."],"exampleFix":"# before\nparser_config = {\"raptor\": {\"prompt\": HUGE_100K_CHAR_PROMPT, ...}}\n\n# after\nassert len(json.dumps(parser_config, separators=(',',':'))) <= 65535\nresp = client.post(\"/api/v1/datasets\", json={\"parser_config\": parser_config, ...})","handlingStrategy":"validation","validationCode":"import json\n\nMAX = 65535\n\ndef check_parser_config(cfg: dict | None) -> None:\n    if cfg is None:\n        return\n    size = len(json.dumps(cfg, separators=(\",\", \":\"), ensure_ascii=False))\n    if size > MAX:\n        raise ValueError(f\"parser_config serializes to {size} chars (max {MAX}); trim raptor prompts or page ranges\")","typeGuard":null,"tryCatchPattern":"try:\n    api.create_dataset(payload)\nexcept ValidationError as e:\n    if any(err[\"type\"] == \"string_too_long\" and \"Parser config\" in str(err) for err in e.errors()):\n        trim_raptor_prompt(payload)\n        api.create_dataset(payload)","preventionTips":["Measure compact-JSON length client-side before every dataset create/update.","Keep LLM prompts out of parser_config; put them in model settings.","Cap generated page-range lists programmatically."],"tags":["parser-config","size-limit","validation","datasets"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}