{"record":{"id":"be1e2b131b4e2dbc","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"session-id-must-be-a-non-empty-string","errorCode":null,"errorMessage":"session_id must be a non-empty string","messagePattern":"session_id must be a non-empty string","errorType":"validation","errorClass":"ParamError","httpStatus":null,"severity":"error","filePath":"sdk/memory-core/python/tencentdb_agent_memory/v3/client.py","lineNumber":312,"sourceCode":"        session_id: Optional[str] = None,\n    ) -> Dict[str, Any]:\n        \"\"\"``POST /v3/conversation/delete`` — 批量删除 L0。\n\n        ``message_ids``（≤5000）与 ``session_ids``（≤100）至少给一个，可同时给。\n\n        注意作用域：这里**不会**回退到构造时的 ``session_id``。删除是破坏性\n        操作，若像读接口那样自动带上默认 session，只想按 message_ids 删几条\n        的调用方会意外把整个会话删掉。要删会话必须显式传 ``session_ids``。\n\n        ``session_id``（单数）已废弃，保留仅为兼容旧调用方，会合并进\n        ``session_ids``。\n        \"\"\"\n        normalized_messages = _normalize_delete_ids(\"message_ids\", message_ids, 5000)\n        normalized_sessions = _normalize_delete_ids(\"session_ids\", session_ids, 100)\n\n        if session_id is not None:\n            if not isinstance(session_id, str) or not session_id.strip():\n                raise ParamError(\"session_id must be a non-empty string\")\n            merged = list(normalized_sessions or [])\n            if session_id.strip() not in merged:\n                merged.append(session_id.strip())\n            normalized_sessions = merged\n\n        if not normalized_messages and not normalized_sessions:\n            raise ParamError(\n                \"delete_conversation requires message_ids or session_ids \"\n                \"(the constructor session_id is intentionally NOT used for deletes)\"\n            )\n\n        return self._stub.post(\n            f\"{_V3}/conversation/delete\",\n            _strip_none({\n                **self._iso.base_body(),\n                \"message_ids\": normalized_messages,\n                \"session_ids\": normalized_sessions,\n            }),","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/sdk/memory-core/python/tencentdb_agent_memory/v3/client.py#L294-L330","documentation":"In delete_conversation, an explicitly provided session_id parameter must be a non-empty, non-whitespace string. Passing None is allowed (it is simply ignored), but an empty string, whitespace-only string, or non-string value raises ParamError.","triggerScenarios":"Calling delete_conversation(session_id=\"\") or session_id=\"   \"; passing a non-string (int, UUID object) as session_id; forwarding an optional variable that is an empty string rather than None.","commonSituations":"Config or request payloads where the session id defaulted to empty string instead of None; a upstream caller converting None to '' via str(None) or default substitutions.","solutions":["Pass a stripped non-empty session_id string, or omit the parameter (None) entirely","Normalize before calling: session_id = (raw or '').strip() or None","Coerce non-strings explicitly: session_id = str(session_id) when it is guaranteed non-empty","Ensure optional fields serialize to None, not '', when absent"],"exampleFix":"// before\nclient.delete_conversation(session_id=session_id or \"\")  # '' raises\n// after\nsid = session_id.strip() if isinstance(session_id, str) else None\nclient.delete_conversation(session_id=sid or None)","handlingStrategy":"type-guard","validationCode":"def clean_session_id(v):\n    if v is None:\n        return None\n    if isinstance(v, str) and v.strip():\n        return v.strip()\n    raise ValueError(\"session_id must be a non-empty string or None\")","typeGuard":"def is_valid_session_id(v) -> bool:\n    return v is None or (isinstance(v, str) and bool(v.strip()))","tryCatchPattern":"try:\n    client.delete_conversation(session_id=sid)\nexcept ParamError as e:\n    if \"non-empty string\" in str(e):\n        sid = None  # fall back to session_ids-based delete\n        client.delete_conversation(session_ids=[...])","preventionTips":["Normalize optional string params to None instead of '' when absent","Never pass str(None) or unset template placeholders as session ids","Strip session ids at the API boundary of your own service","Use a dedicated SessionId type/wrapper to avoid raw strings"],"tags":["python","validation","parameter-error"],"backgroundTag":"invalid-parameter-list","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}