TencentCloud/TencentDB-Agent-Memory · error · ParamError

{name} must be a non-empty string

Error message

{name} must be a non-empty string

What it means

_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.

Source

Thrown at sdk/memory-core/python/tencentdb_agent_memory/v3/memory_generation_log.py:19

"""Clients for ``/v3/memory-generation-log/*`` APIs."""
from __future__ import annotations

from typing import Any, Dict, Optional

from .._http import Stub
from .._v3_http import AsyncHttpStub, HttpStub
from ..errors import ParamError

_ROOT = "/v3/memory-generation-log"


def _strip_none(value: Dict[str, Any]) -> Dict[str, Any]:
    return {key: item for key, item in value.items() if item is not None}


def _required(name: str, value: str) -> str:
    if not isinstance(value, str) or not value.strip():
        raise ParamError(f"{name} must be a non-empty string")
    return value


class MemoryGenerationLogClient:
    def __init__(self, endpoint: str = "", api_key: str = "", service_id: Optional[str] = None,
                 *, timeout: float = 30, verify: bool = True, stub: Optional[Stub] = None) -> None:
        if stub is not None:
            self._stub = stub
        else:
            if not service_id:
                raise ParamError("service_id must be provided")
            self._stub = HttpStub(endpoint, api_key, service_id, timeout=timeout, verify=verify)

    def _get(self, path: str, query: Dict[str, Any]) -> Dict[str, Any]:
        method = getattr(self._stub, "get", None)
        return method(path, query) if method else self._stub.post(path, query)

    def list(self, *, layer: Optional[str] = None, status: Optional[str] = None,

View on GitHub (pinned to 3efcd317b8)

Solutions

  1. Pass a non-empty string id, e.g. str(uuid) rather than the UUID object
  2. Check the variable's origin for empty/None values before the lookup
  3. Handle the missing-record flow instead of calling get with a placeholder value

Example fix

// before
log = client.get(memory_id)
// after
if isinstance(memory_id, str) and memory_id.strip():
    log = client.get(memory_id)
Defensive patterns

Strategy: validation

Validate before calling

if not (isinstance(memory_id, str) and memory_id.strip()):
    raise ValueError('memory_id must be a non-empty string')

Type guard

def is_nonempty_str(v: object) -> bool:
    return isinstance(v, str) and bool(v.strip())

Try / catch

try:
    log = client.get(memory_id)
except ParamError as e:
    logger.warning('bad id for get: %s', e)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01). Data as JSON: /api/errors/aeb14a1ac79ecae9. Report an issue: GitHub.