TencentCloud/TencentDB-Agent-Memory · error · ParamError

service_id must be provided

Error message

service_id must be provided

What it means

MemoryGenerationLogClient (sync) only needs service_id when it constructs its own HttpStub. If no pre-built stub is injected and service_id is missing/falsy, the constructor raises this ParamError because it cannot scope requests to a service.

Source

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

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,
             start_time: Optional[str] = None, end_time: Optional[str] = None,
             limit: Optional[int] = None, cursor: Optional[str] = None) -> Dict[str, Any]:
        return self._get(f"{_ROOT}/list", _strip_none({
            "layer": layer, "status": status, "start_time": start_time,
            "end_time": end_time, "limit": limit, "cursor": cursor,
        }))

    def get(self, log_id: str) -> Dict[str, Any]:
        return self._get(f"{_ROOT}/get", {"log_id": _required("log_id", log_id)})

    def get_by_memory_id(self, memory_id: str, layer: str) -> Dict[str, Any]:

View on GitHub (pinned to 3efcd317b8)

Solutions

  1. Pass service_id='your-service-id' to the constructor
  2. Set and read the service id from config/env before constructing
  3. Inject a pre-built Stub if you need custom transport (bypasses the check)

Example fix

// before
client = MemoryGenerationLogClient(endpoint=URL, api_key=KEY)
// after
client = MemoryGenerationLogClient(endpoint=URL, api_key=KEY, service_id=SERVICE_ID)
Defensive patterns

Strategy: validation

Validate before calling

assert service_id, 'service_id is required when no stub is provided'
client = MemoryGenerationLogClient(endpoint=URL, api_key=KEY, service_id=service_id)

Try / catch

try:
    client = MemoryGenerationLogClient(endpoint=URL, api_key=KEY, service_id=service_id)
except ParamError as e:
    raise RuntimeError(f'client misconfigured: {e}') from e

Prevention

When it happens

Trigger: Instantiating MemoryGenerationLogClient(endpoint=..., api_key=...) without service_id and without a stub; service_id passed as empty string; typo'd keyword argument so service_id keeps its None default.

Common situations: Config-driven construction where the service id env var is unset; copying client-construction code that omitted service_id; switching from stub-injected test code to real setup without adding service_id.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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