TencentCloud/TencentDB-Agent-Memory · error · ParamError
{field} must contain only non-empty strings
Error message
{field} must contain only non-empty strings What it means
_normalize_delete_ids validates that list-style delete inputs (message_ids, session_ids, ids, memory_ids) contain only strings that are non-empty after whitespace stripping. Any None, non-str element (int, dict, empty string) triggers this ParamError. It is a client-side guard so malformed IDs never reach the server.
Source
Thrown at sdk/memory-core/python/tencentdb_agent_memory/v3/client.py:69
def _normalize_delete_ids(
field: str,
raw: Optional[List[str]],
max_items: int,
) -> Optional[List[str]]:
"""归一化批量删除的 id 列表:校验非空字符串、去重(保序)、检查上限。
破坏性操作的入参在客户端就拦一道,比等服务端回 400 更早暴露问题,
也避免把明显不合法的批量请求发出去。
:returns: 归一化后的列表;``raw`` 为 None 时返回 None(表示"未提供")。
"""
if raw is None:
return None
if not isinstance(raw, (list, tuple)):
raise ParamError(f"{field} must be a list of non-empty strings")
if any(not isinstance(item, str) or not item.strip() for item in raw):
raise ParamError(f"{field} must contain only non-empty strings")
seen: Dict[str, None] = {}
for item in raw:
seen.setdefault(item.strip(), None)
deduped = list(seen.keys())
if len(deduped) > max_items:
raise ParamError(f"{field} accepts at most {max_items} items, got {len(deduped)}")
return deduped
def _validate_construction(team_id: str, agent_id: str, user_id: str) -> None:
"""v3 构造时 team+agent+user 必填,任一缺失立刻 ParamError,避免 422 才暴露。
session_id 不在构造时强校验(L2/L3 接口不需要);L0/L1 方法调用时再单独校验。
"""
missing = [
name for name, val in (View on GitHub (pinned to 3efcd317b8)
Solutions
- Convert every element to a stripped non-empty string before calling: ids=[str(i).strip() for i in raw_ids if str(i).strip()]
- Check element types before the call: all(isinstance(x, str) and x.strip() for x in ids)
- Fix the source producing the IDs (JSON parsing, DB row extraction) to emit strings
- If you may pass empty lists, that is allowed — only list ELEMENTS must be non-empty strings
Example fix
// before client.delete_atomic(ids=[12345, "", None]) // after clean = [str(i).strip() for i in raw_ids if isinstance(i, str) and i.strip()] client.delete_atomic(ids=clean)
Defensive patterns
Strategy: validation
Validate before calling
def valid_delete_ids(ids):
return isinstance(ids, (list, tuple)) and all(isinstance(i, str) and i.strip() for i in ids)
# call only if valid_delete_ids(message_ids) Type guard
def as_str_list(raw) -> list[str] | None:
if isinstance(raw, (list, tuple)) and all(isinstance(i, str) for i in raw):
return [i for i in raw if i.strip()]
return None Try / catch
try:
client.delete_conversation(message_ids=ids)
except ParamError as e:
logger.error("bad delete ids: %s", e)
ids = [str(i).strip() for i in ids if str(i).strip()]
client.delete_conversation(message_ids=ids) Prevention
- Coerce all id sources to stripped strings at ingestion time
- Add a shared normalize_ids helper used by every caller
- Type-annotate id params as list[str] and run mypy
- Reject numeric ids at the JSON parse boundary, not at the SDK call
When it happens
Trigger: Calling delete_conversation, delete_atomic, or clear_chat_memory with a list containing non-string items (e.g. ints from JSON without str conversion), empty strings, whitespace-only strings, or None elements inside the list.
Common situations: IDs parsed from JSON/YAML where numeric IDs stay unquoted; DB drivers returning ints; f-string interpolation producing 'None' or empty values; collecting IDs from a dict iteration that yields non-strings.
Related errors
- session_id must be a non-empty string
- delete_atomic requires a non-empty ids list
- clear_chat_memory requires a non-empty memory_ids list
- {field} accepts at most {max_items} items, got {len(deduped)
- v3 MemoryClient requires non-empty {', '.join(missing)} at c
AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01).
Data as JSON: /api/errors/d6e688ef003cb40a.
Report an issue: GitHub.