{"record":{"id":"aeb14a1ac79ecae9","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"name-must-be-a-non-empty-string","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_generation_log.py","lineNumber":19,"sourceCode":"\"\"\"Clients for ``/v3/memory-generation-log/*`` APIs.\"\"\"\nfrom __future__ import annotations\n\nfrom typing import Any, Dict, Optional\n\nfrom .._http import Stub\nfrom .._v3_http import AsyncHttpStub, HttpStub\nfrom ..errors import ParamError\n\n_ROOT = \"/v3/memory-generation-log\"\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\nclass MemoryGenerationLogClient:\n    def __init__(self, endpoint: str = \"\", api_key: str = \"\", service_id: Optional[str] = None,\n                 *, timeout: float = 30, verify: bool = True, stub: Optional[Stub] = None) -> None:\n        if stub is not None:\n            self._stub = stub\n        else:\n            if not service_id:\n                raise ParamError(\"service_id must be provided\")\n            self._stub = HttpStub(endpoint, api_key, service_id, timeout=timeout, verify=verify)\n\n    def _get(self, path: str, query: Dict[str, Any]) -> Dict[str, Any]:\n        method = getattr(self._stub, \"get\", None)\n        return method(path, query) if method else self._stub.post(path, query)\n\n    def list(self, *, layer: Optional[str] = None, status: Optional[str] = None,","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/sdk/memory-core/python/tencentdb_agent_memory/v3/memory_generation_log.py#L1-L37","documentation":"_required in memory_generation_log.py validates string parameters (used by get and get_by_memory_id, e.g. the memory_id/log id). If the value is not a str or is empty/whitespace-only, a ParamError naming the parameter is raised before any request is made.","triggerScenarios":"Calling log_client.get(id='') or get_by_memory_id(memory_id=' '), or passing None/a non-string into the id argument from an unset variable.","commonSituations":"A lookup after a failed write where the memory_id was never populated; optional upstream values treated as required; passing a UUID object instead of its string form.","solutions":["Pass a non-empty string id, e.g. str(uuid) rather than the UUID object","Check the variable's origin for empty/None values before the lookup","Handle the missing-record flow instead of calling get with a placeholder value"],"exampleFix":"// before\nlog = client.get(memory_id)\n// after\nif isinstance(memory_id, str) and memory_id.strip():\n    log = client.get(memory_id)","handlingStrategy":"validation","validationCode":"if not (isinstance(memory_id, str) and memory_id.strip()):\n    raise ValueError('memory_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    log = client.get(memory_id)\nexcept ParamError as e:\n    logger.warning('bad id for get: %s', e)","preventionTips":["Cast UUID/id objects with str() before lookups","Validate ids at the data-entry boundary","Treat empty-id lookups as 'not found' rather than calling the API"],"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"}