{"record":{"id":"81477a19fb44319d","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"name-must-be-a-non-empty-string-81477a","errorCode":null,"errorMessage":"{name} must be a non-empty string","messagePattern":"(.+?) must be a non-empty string","errorType":"validation","errorClass":"ParamError","httpStatus":null,"severity":"error","filePath":"sdk/memory-core/python/tencentdb_agent_memory/v3/memory_prompt.py","lineNumber":19,"sourceCode":"\"\"\"Clients for ``/v3/memory-prompt/*`` management APIs.\"\"\"\nfrom __future__ import annotations\n\nfrom typing import Any, Dict, Iterable, List, Optional\n\nfrom .._http import Stub\nfrom .._v3_http import AsyncHttpStub, HttpStub\nfrom ..errors import ParamError\n\n_ROOT = \"/v3/memory-prompt\"\n\n\ndef _strip_none(value: Dict[str, Any]) -> Dict[str, Any]:\n    return {key: item for key, item in value.items() if item is not None}\n\n\ndef _required(name: str, value: str) -> str:\n    if not isinstance(value, str) or not value.strip():\n        raise ParamError(f\"{name} must be a non-empty string\")\n    return value\n\n\ndef _ids(values: Iterable[str], name: str) -> List[str]:\n    result = list(dict.fromkeys(values))\n    if not result or any(not isinstance(item, str) or not item.strip() for item in result):\n        raise ParamError(f\"{name} must be a non-empty list of non-empty strings\")\n    return result\n\n\ndef _target(team_id: Optional[str], agent_ids: Optional[List[str]]) -> None:\n    if agent_ids is not None:\n        _ids(agent_ids, \"agent_ids\")\n        if not team_id:\n            raise ParamError(\"team_id is required with agent_ids\")\n\n\nclass MemoryPromptClient:","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/sdk/memory-core/python/tencentdb_agent_memory/v3/memory_prompt.py#L1-L37","documentation":"_required in memory_prompt.py is the same fail-fast string validator used by MemoryPromptClient.get and get_by_memory_id. Any id argument that is not a non-empty, non-whitespace string raises a ParamError naming the parameter before an HTTP call happens.","triggerScenarios":"prompt_client.get(prompt_id='') or get_by_memory_id(memory_id=None) — e.g. an id variable that was never assigned, a whitespace-padded placeholder, or a non-string type.","commonSituations":"Chained lookups where an earlier step returned an empty id; deserialized JSON with missing keys defaulting to ''; passing None when a record was expected to exist.","solutions":["Validate the id is a non-empty string before the call","Fix the upstream step that produced the empty id","Use the listing APIs to obtain a valid id instead of guessing one"],"exampleFix":"// before\nprompt = client.get_by_memory_id(memory_id)\n// after\nif not (isinstance(memory_id, str) and memory_id.strip()):\n    raise ValueError('memory_id is required')\nprompt = client.get_by_memory_id(memory_id)","handlingStrategy":"validation","validationCode":"if not (isinstance(prompt_id, str) and prompt_id.strip()):\n    raise ValueError('prompt_id must be a non-empty string')","typeGuard":"def is_nonempty_str(v: object) -> bool:\n    return isinstance(v, str) and bool(v.strip())","tryCatchPattern":"try:\n    prompt = prompt_client.get(prompt_id)\nexcept ParamError as e:\n    logger.warning('invalid prompt id: %s', e)","preventionTips":["Check ids exist before chained lookups","Use .strip() normalization on ids from external sources","Type-hint id params as str (not Optional[str]) when required"],"tags":["python","parameter-validation"],"backgroundTag":"empty-required-parameter","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}