{"record":{"id":"b9ecbc02bc16a0f4","repo":"iflytek/astron-agent","slug":"chunkids-is-not-empty","errorCode":null,"errorMessage":"chunkIds is not empty","messagePattern":"chunkIds is not empty","errorType":"validation","errorClass":"ProtocolParamException","httpStatus":null,"severity":"error","filePath":"core/knowledge/service/impl/cbg_strategy.py","lineNumber":317,"sourceCode":"    async def chunks_delete(\n        self, docId: str, chunkIds: List[str], **kwargs: Any\n    ) -> Any:\n        \"\"\"\n        Delete chunks\n\n        Args:\n            docId: Document ID\n            chunkIds: Chunk ID list\n            **kwargs: Other parameters\n\n        Returns:\n            Delete result\n\n        Raises:\n            ProtocolParamException: When chunkIds is empty\n        \"\"\"\n        if not check_not_empty(chunkIds):\n            raise ProtocolParamException(msg=\"chunkIds is not empty\")\n\n        return await xinghuo.dataset_delchunk(chunk_ids=chunkIds, **kwargs)\n\n    async def query_doc(self, docId: str, **kwargs: Any) -> List[dict]:\n        \"\"\"\n        Query all chunks of a document\n\n        Args:\n            docId: Document ID\n            **kwargs: Other parameters\n\n        Returns:\n            List of chunk information\n        \"\"\"\n        result: List[dict] = []\n        datas = await xinghuo.get_chunks(file_id=docId, **kwargs)\n\n        for data in datas:","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/knowledge/service/impl/cbg_strategy.py#L299-L335","documentation":"chunks_delete validates that a non-empty chunkIds list is supplied; check_not_empty failing raises ProtocolParamException('chunkIds is not empty') before invoking xinghuo.dataset_delchunk. Deleting with no target chunk IDs is treated as a caller bug.","triggerScenarios":"Calling chunks_delete() with chunkIds=None or [] — e.g. the UI allowed deleting with nothing selected, or the chunk list was emptied by a prior filter.","commonSituations":"Frontend submitting a delete request with no checkboxes selected; chunks already deleted so the filtered id list is empty; id field name mismatch leaving the list unset.","solutions":["Ensure chunkIds contains at least one chunk id before calling chunks_delete()","Guard the call site: skip or no-op the delete when the id list is empty","Check the selection/fetch logic that builds chunkIds — it may be dropping ids","Verify the chunks still exist; if already deleted, treat the operation as complete instead of calling the API"],"exampleFix":"// before\nawait strategy.chunks_delete(chunkIds=chunk_ids)\n// after\nif chunk_ids:\n    await strategy.chunks_delete(chunkIds=chunk_ids)","handlingStrategy":"validation","validationCode":"if not chunk_ids:\n    return {\"deleted\": 0}  # no-op instead of calling the API","typeGuard":"def has_chunk_ids(v) -> bool:\n    return isinstance(v, (list, tuple)) and len(v) > 0 and all(isinstance(i, str) and i for i in v)","tryCatchPattern":"try:\n    await strategy.chunks_delete(chunkIds=ids)\nexcept ProtocolParamException:\n    logger.info(\"No chunk ids to delete; skipping\")","preventionTips":["No-op delete requests with empty id lists at the service layer","Disable the delete action in UI until at least one chunk is selected","Verify chunks still exist before batch deletes","Unit-test chunks_delete with empty and None inputs"],"tags":["validation","parameter","delete"],"backgroundTag":"empty-required-field","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"}