{"record":{"id":"d8db53938a18fd62","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"service-id-must-be-provided-d8db53","errorCode":null,"errorMessage":"service_id must be provided","messagePattern":"service_id must be provided","errorType":"validation","errorClass":"ParamError","httpStatus":null,"severity":"error","filePath":"sdk/memory-core/python/tencentdb_agent_memory/v3/memory_generation_log.py","lineNumber":30,"sourceCode":"\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,\n             start_time: Optional[str] = None, end_time: Optional[str] = None,\n             limit: Optional[int] = None, cursor: Optional[str] = None) -> Dict[str, Any]:\n        return self._get(f\"{_ROOT}/list\", _strip_none({\n            \"layer\": layer, \"status\": status, \"start_time\": start_time,\n            \"end_time\": end_time, \"limit\": limit, \"cursor\": cursor,\n        }))\n\n    def get(self, log_id: str) -> Dict[str, Any]:\n        return self._get(f\"{_ROOT}/get\", {\"log_id\": _required(\"log_id\", log_id)})\n\n    def get_by_memory_id(self, memory_id: str, layer: str) -> Dict[str, Any]:","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/sdk/memory-core/python/tencentdb_agent_memory/v3/memory_generation_log.py#L12-L48","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass service_id='your-service-id' to the constructor","Set and read the service id from config/env before constructing","Inject a pre-built Stub if you need custom transport (bypasses the check)"],"exampleFix":"// before\nclient = MemoryGenerationLogClient(endpoint=URL, api_key=KEY)\n// after\nclient = MemoryGenerationLogClient(endpoint=URL, api_key=KEY, service_id=SERVICE_ID)","handlingStrategy":"validation","validationCode":"assert service_id, 'service_id is required when no stub is provided'\nclient = MemoryGenerationLogClient(endpoint=URL, api_key=KEY, service_id=service_id)","typeGuard":null,"tryCatchPattern":"try:\n    client = MemoryGenerationLogClient(endpoint=URL, api_key=KEY, service_id=service_id)\nexcept ParamError as e:\n    raise RuntimeError(f'client misconfigured: {e}') from e","preventionTips":["Fail fast on missing config at startup, not at first API use","Keep one config-loading module that validates service_id presence","Note the stub kwarg bypasses this check — only for tests/custom transport"],"tags":["python","configuration","initialization"],"backgroundTag":"missing-required-argument","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}