{"record":{"id":"59ba717084b3c7fa","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"delete-atomic-requires-a-non-empty-ids-list","errorCode":null,"errorMessage":"delete_atomic requires a non-empty ids list","messagePattern":"delete_atomic requires a non-empty ids list","errorType":"validation","errorClass":"ParamError","httpStatus":null,"severity":"error","filePath":"sdk/memory-core/python/tencentdb_agent_memory/v3/client.py","lineNumber":430,"sourceCode":"                \"session_id\": self._iso.resolve_session(session_id),\n                \"query\": query,\n                \"limit\": limit,\n                \"type\": type,\n                \"time_start\": time_start,\n                \"time_end\": time_end,\n            }),\n        )\n\n    def delete_atomic(\n        self,\n        ids: List[str],\n        *,\n        session_id: Optional[str] = None,\n    ) -> Dict[str, Any]:\n        \"\"\"``POST /v3/atomic/delete`` — ids必填，单次至多 5000 条。\"\"\"\n        normalized = _normalize_delete_ids(\"ids\", ids, 5000)\n        if not normalized:\n            raise ParamError(\"delete_atomic requires a non-empty ids list\")\n        return self._stub.post(\n            f\"{_V3}/atomic/delete\",\n            _strip_none({\n                **self._iso.base_body(),\n                \"session_id\": self._iso.resolve_session(session_id),\n                \"ids\": normalized,\n            }),\n        )\n\n    def count_atomic(\n        self,\n        *,\n        type: Optional[str] = None,\n        time_start: Optional[str] = None,\n        time_end: Optional[str] = None,\n        session_id: Optional[str] = None,\n    ) -> Dict[str, Any]:\n        \"\"\"``POST /v3/atomic/count`` — 与 query 同过滤器，仅返回 ``{total}``.\"\"\"","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/sdk/memory-core/python/tencentdb_agent_memory/v3/client.py#L412-L448","documentation":"delete_atomic posts to /v3/atomic/delete which deletes by explicit ids; the ids list is mandatory and must contain at least one valid item after normalization/dedup. An empty list (or one whose elements were all invalid) raises ParamError rather than issuing a no-op request.","triggerScenarios":"delete_atomic(ids=[]) ; delete_atomic(ids=['', '  ']) where every element fails stripping; passing an id list variable that ended up empty after filtering.","commonSituations":"Conditional scripts where the id-collection step produced nothing; forwarding a possibly-empty list from upstream config; forgetting that normalization strips/dedups before the emptiness check.","solutions":["Ensure at least one non-empty id: delete_atomic(ids=[\"mem-123\"])\n","Guard before calling: if ids: client.delete_atomic(ids=ids)\n","If nothing to delete, skip the call entirely instead of sending an empty batch","If elements were filtered out upstream, fix the filter so valid ids survive"],"exampleFix":"// before\nclient.delete_atomic(ids=stale_ids)  # stale_ids may be []\n// after\nif stale_ids:\n    client.delete_atomic(ids=stale_ids)","handlingStrategy":"validation","validationCode":"def delete_atomic_safe(client, ids):\n    clean = [i for i in ids if isinstance(i, str) and i.strip()]\n    return client.delete_atomic(ids=clean) if clean else None","typeGuard":"def nonempty_str_list(v) -> bool:\n    return isinstance(v, (list, tuple)) and len(v) > 0 and all(isinstance(i, str) and i.strip() for i in v)","tryCatchPattern":"try:\n    client.delete_atomic(ids=ids)\nexcept ParamError as e:\n    if \"non-empty ids list\" in str(e):\n        logger.info(\"nothing to delete, skipping atomic delete\")","preventionTips":["Skip API calls when the id list is empty instead of calling with []","Guard list-building code so filters cannot silently empty the list","Log the count of ids before destructive batch calls","Treat empty input as a no-op path in cleanup scripts"],"tags":["python","validation","parameter-error"],"backgroundTag":"empty-required-list","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}