{"record":{"id":"a317026d9870ac38","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"service-id-must-be-provided-a31702","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_prompt.py","lineNumber":47,"sourceCode":"\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:\n    \"\"\"Synchronous Prompt CRUD, target binding, resolution and setting-log client.\"\"\"\n\n    def __init__(self, endpoint: str = \"\", api_key: str = \"\", service_id: Optional[str] = None,\n                 *, team_id: Optional[str] = None, agent_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        self._team_id = team_id\n        self._agent_id = agent_id\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 create(self, *, name: str, layer: str, prompt: str) -> Dict[str, Any]:\n        return self._stub.post(f\"{_ROOT}/create\", {\n            \"name\": _required(\"name\", name), \"layer\": layer, \"prompt\": _required(\"prompt\", prompt),\n        })\n\n    def get(self, memory_prompt_id: str) -> Dict[str, Any]:\n        return self._get(f\"{_ROOT}/get\", {\"memory_prompt_id\": _required(\"memory_prompt_id\", memory_prompt_id)})\n\n    def list(self, *, layer: Optional[str] = None, limit: Optional[int] = None,\n             offset: Optional[int] = None, time_order: Optional[str] = None) -> Dict[str, Any]:","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/sdk/memory-core/python/tencentdb_agent_memory/v3/memory_prompt.py#L29-L65","documentation":"MemoryPrompt's sync client __init__ raises ParamError when neither a stub nor a service_id is supplied. The HTTP stub needs the service_id to route requests to the correct TencentDB memory service, so without it the client cannot be constructed. This is a fail-fast constructor guard, not a runtime/network failure.","triggerScenarios":"Instantiating the sync MemoryPrompt class without passing service_id while also omitting the stub argument (e.g. MemoryPrompt(endpoint=..., api_key=...) or service_id=None/\"\").","commonSituations":"Developers assume api_key and endpoint are enough (like other SDKs), copy setup code that pulls service_id from an env var that is unset, or migrate from a stub-based setup to direct HTTP and forget the new required parameter.","solutions":["Pass the service_id string to the MemoryPrompt constructor.","Load it from an environment variable and assert it is non-empty before constructing the client.","If testing or using custom transport, inject a stub object instead of endpoint/api_key/service_id."],"exampleFix":"# before\nclient = MemoryPrompt(endpoint=ENDPOINT, api_key=API_KEY, team_id=\"t1\")\n\n# after\nclient = MemoryPrompt(endpoint=ENDPOINT, api_key=API_KEY, service_id=\"my-service-id\", team_id=\"t1\")","handlingStrategy":"validation","validationCode":"service_id = os.getenv(\"TDB_MEMORY_SERVICE_ID\", \"\").strip()\nif not service_id:\n    raise ValueError(\"TDB_MEMORY_SERVICE_ID is required to build MemoryPrompt\")\nclient = MemoryPrompt(endpoint=ENDPOINT, api_key=API_KEY, service_id=service_id)","typeGuard":"def has_service_id(cfg: dict) -> bool:\n    return isinstance(cfg.get(\"service_id\"), str) and bool(cfg[\"service_id\"].strip())","tryCatchPattern":"try:\n    client = MemoryPrompt(endpoint=E, api_key=K, service_id=S)\nexcept ParamError as e:\n    logging.error(\"Client init failed: %s\", e)\n    raise SystemExit(2)","preventionTips":["Centralize client construction in one factory that validates all required config.","Fail fast on empty env vars at startup rather than at first API call.","Prefer explicit constructor arguments over partially-populated config dicts."],"tags":["python","parameter-validation","constructor","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}