{"record":{"id":"55fea1a74e5cc7a1","repo":"iflytek/astron-agent","slug":"missingparameter","errorCode":"MissingParameter","errorMessage":"chunks parameter cannot be empty","messagePattern":"chunks parameter cannot be empty","errorType":"error_code","errorClass":"CustomException","httpStatus":null,"severity":"error","filePath":"core/knowledge/service/impl/ragflow_strategy.py","lineNumber":795,"sourceCode":"        Returns:\n            List of save results in format:\n            [\n                {\n                    \"id\": \"chunk_id\",\n                    \"datasetId\": \"dataset_id\",\n                    \"fileId\": \"doc_id\",\n                    \"createTime\": \"2025-09-15 14:41:19\",\n                    \"updateTime\": \"2025-09-15 14:41:19\",\n                    \"chunkType\": \"RAW\",\n                    \"content\": \"chunk content\",\n                    \"dataIndex\": 0.0,\n                    \"imgReference\": {}\n                }\n            ]\n        \"\"\"\n        if not check_not_empty(chunks):\n            logger.error(\"Chunks list is empty or invalid\")\n            raise CustomException(\n                CodeEnum.MissingParameter, \"chunks parameter cannot be empty\"\n            )\n\n        logger.info(\n            f\"Starting chunk save request: docId={docId}, chunks_count={len(chunks)}\"\n        )\n\n        try:\n            dataset_id = await self._validate_chunks_save_config(\n                docId, dataset_id=kwargs.get(_DATASET_ID_KWARG)\n            )\n            logger.info(f\"Using dataset: {dataset_id}\")\n\n            await self._validate_document_exists(dataset_id, docId)\n\n            existing_chunks = await self._get_existing_chunks(dataset_id, docId)\n\n            current_time = time.strftime(\"%Y-%m-%d %H:%M:%S\")","sourceCodeStart":777,"sourceCodeEnd":813,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/knowledge/service/impl/ragflow_strategy.py#L777-L813","documentation":"chunks_save validates the chunks payload with check_not_empty; an empty chunks list raises 'chunks parameter cannot be empty' because saving zero chunks would be a no-op that likely signals an upstream chunking failure.","triggerScenarios":"chunks_save called with chunks=None, chunks=[], or a non-list value; upstream pipeline produced zero chunks from an empty/blank document.","commonSituations":"Empty document passed through a splitter yielding no segments; frontend submitted the save form without chunk data; a transformation step dropped all items silently.","solutions":["Guard the caller: skip chunks_save entirely when the chunk list is empty.","Fix the splitting/production step so a non-empty document yields at least one chunk.","Validate request payload on the API layer to reject empty chunks earlier with a clearer message.","If saving zero chunks is legitimate, change the caller to a no-op instead of invoking the API."],"exampleFix":"// before\nchunks = split_document(doc)  # may return []\nawait strategy.chunks_save(docId=doc_id, chunks=chunks, dataset_id=ds)\n// after\nchunks = split_document(doc)\nif not chunks:\n    logger.info(\"No chunks to save for %s, skipping\", doc_id)\n    return\nawait strategy.chunks_save(docId=doc_id, chunks=chunks, dataset_id=ds)","handlingStrategy":"validation","validationCode":"if not chunks:\n    logger.info(\"no chunks for %s; skipping save\", doc_id)\n    return\nawait strategy.chunks_save(docId=doc_id, chunks=chunks, dataset_id=ds)","typeGuard":"def has_chunks(chunks) -> bool:\n    return isinstance(chunks, list) and len(chunks) > 0","tryCatchPattern":"try:\n    await strategy.chunks_save(docId=doc_id, chunks=chunks, dataset_id=ds)\nexcept CustomException as e:\n    if \"chunks parameter cannot be empty\" in str(e):\n        logger.warning(\"empty chunk batch submitted for %s\", doc_id)\n    else:\n        raise","preventionTips":["Treat zero-chunk results as a legitimate no-op upstream.","Validate request bodies at the API layer before reaching the strategy.","Log splitter output counts to catch silent empty productions."],"tags":["validation","missing-parameter","chunks","empty-list"],"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"}