{"record":{"id":"71df77dc54f12f0f","repo":"iflytek/astron-agent","slug":"file-is-required","errorCode":null,"errorMessage":"file is required","messagePattern":"file is required","errorType":"validation","errorClass":"ProtocolParamException","httpStatus":null,"severity":"error","filePath":"core/knowledge/service/impl/cbg_strategy.py","lineNumber":199,"sourceCode":"        Split file into multiple chunks\n\n        Args:\n            fileUrl: File URL\n            lengthRange: Length range\n            overlap: Overlap length\n            resourceType: Resource type\n            separator: Separator list\n            titleSplit: Whether to split by title\n            cutOff: Cutoff marker list\n            **kwargs: Other parameters\n\n        Returns:\n            List of split chunks\n        \"\"\"\n        if fileUrl is None:\n            fileUrl = \"\"\n            if not kwargs.get(\"file\"):\n                raise ProtocolParamException(msg=\"file is required\")\n\n        data = []\n        wiki_split_extends: Dict[str, Any] = {}\n\n        if check_not_empty(separator) and separator is not None:\n            split_chars = []\n            for chars in separator:\n                split_chars.append(\n                    base64.b64encode(chars.encode(\"utf-8\")).decode(encoding=\"utf-8\")\n                )\n            wiki_split_extends[\"chunkSeparators\"] = split_chars\n        else:\n            wiki_split_extends[\"chunkSeparators\"] = [\"DQo=\"]\n\n        if (\n            check_not_empty(lengthRange)\n            and lengthRange is not None\n            and len(lengthRange) > 1","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/knowledge/service/impl/cbg_strategy.py#L181-L217","documentation":"CbgStrategy.split raises ProtocolParamException('file is required') when neither fileUrl nor kwargs['file'] is provided. Unlike AIUI, the CBG strategy can split from an uploaded file, but it requires at least one of the two inputs.","triggerScenarios":"Calling split() with fileUrl=None and no 'file' entry in kwargs — the caller supplied neither a URL nor an uploaded file object/bytes.","commonSituations":"Upload step failed or was skipped so no file reached the strategy; wrong kwarg name used (e.g. 'file_url' or 'filePath' instead of file/fileUrl); request payload missing the multipart file part.","solutions":["Pass either fileUrl or the uploaded file (kwargs['file']) to split()","Check the caller uses the exact kwarg name 'file' for the upload","Verify the document upload pipeline produced a file/URL before invoking split","If you have a URL only, set fileUrl; if you have bytes/UploadFile, pass file="],"exampleFix":"// before\nawait strategy.split(separator=[\"。\"])  # no file/fileUrl\n// after\nawait strategy.split(file=upload_file, separator=[\"。\"])\n// or\nawait strategy.split(fileUrl=\"https://oss.example.com/doc.pdf\", separator=[\"。\"])","handlingStrategy":"validation","validationCode":"file = kwargs.get(\"file\")\nif not fileUrl and not file:\n    raise ValueError(\"Provide either fileUrl or an uploaded 'file' before calling split\")","typeGuard":"def has_split_input(fileUrl, kwargs: dict) -> bool:\n    return bool(fileUrl) or bool(kwargs.get(\"file\"))","tryCatchPattern":"try:\n    chunks = await strategy.split(file=file)\nexcept ProtocolParamException as e:\n    logger.warning(f\"Missing parameter: {e.msg}\")\n    raise BadRequest(e.msg)","preventionTips":["Guarantee the upload step completes before invoking split","Use consistent kwarg names (file / fileUrl) across strategies","Validate multipart uploads at the API boundary","Test both file- and URL-based split paths"],"tags":["validation","parameter","file-upload"],"backgroundTag":"missing-required-argument","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}