{"record":{"id":"44b09e66a3e88767","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"v3-memoryclient-requires-non-empty-join-miss","errorCode":null,"errorMessage":"v3 MemoryClient requires non-empty {', '.join(missing)} at construction time","messagePattern":"v3 MemoryClient requires non-empty (.+?) at construction time","errorType":"validation","errorClass":"ParamError","httpStatus":null,"severity":"error","filePath":"sdk/memory-core/python/tencentdb_agent_memory/v3/client.py","lineNumber":94,"sourceCode":"    if len(deduped) > max_items:\n        raise ParamError(f\"{field} accepts at most {max_items} items, got {len(deduped)}\")\n    return deduped\n\n\ndef _validate_construction(team_id: str, agent_id: str, user_id: str) -> None:\n    \"\"\"v3 构造时 team+agent+user 必填，任一缺失立刻 ParamError，避免 422 才暴露。\n\n    session_id 不在构造时强校验（L2/L3 接口不需要）；L0/L1 方法调用时再单独校验。\n    \"\"\"\n    missing = [\n        name for name, val in (\n            (\"team_id\", team_id),\n            (\"agent_id\", agent_id),\n            (\"user_id\", user_id),\n        ) if not val\n    ]\n    if missing:\n        raise ParamError(\n            f\"v3 MemoryClient requires non-empty {', '.join(missing)} at construction time\"\n        )\n\n\nclass _IsolationCtx:\n    \"\"\"Carrier for the v3 isolation context. Internal only; exposed via with_isolation().\"\"\"\n\n    __slots__ = (\"team_id\", \"agent_id\", \"user_id\", \"session_id\", \"task_id\")\n\n    def __init__(\n        self,\n        team_id: str,\n        agent_id: str,\n        user_id: str,\n        session_id: Optional[str] = None,\n        task_id: Optional[str] = None,\n    ) -> None:\n        self.team_id = team_id","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/sdk/memory-core/python/tencentdb_agent_memory/v3/client.py#L76-L112","documentation":"v3 MemoryClient requires team_id, agent_id, and user_id — the isolation triple — to be non-empty at construction time. Rather than failing later with a server 422, _validate_construction raises ParamError immediately listing every missing field.","triggerScenarios":"Instantiating MemoryClient or AsyncMemoryClient with empty-string or None team_id/agent_id/user_id, or with_isolation() with any of the triple omitted/blank. Only fields that are falsy are reported; all missing ones are named in the message.","commonSituations":"Config read from env vars where a var is unset/empty; copy-pasting a client snippet from another project without the team/agent ids; upgrading from an API version where these were optional; template rendering leaving placeholders empty.","solutions":["Pass non-empty team_id, agent_id, and user_id to the constructor","Verify the env/config values actually populate (e.g. os.environ['TEAM_ID'] not '')","For isolated sub-clients use with_isolation() supplying all three values","Print the config object before constructing to confirm no blank fields"],"exampleFix":"// before\nclient = MemoryClient(endpoint=ep, api_key=key, service_id=sid, team_id=os.getenv(\"TEAM_ID\"))\n# after\nteam_id = os.environ[\"TEAM_ID\"]  # fail fast if unset\nagent_id = os.environ[\"AGENT_ID\"]\nuser_id = os.environ[\"USER_ID\"]\nclient = MemoryClient(endpoint=ep, api_key=key, service_id=sid,\n                      team_id=team_id, agent_id=agent_id, user_id=user_id)","handlingStrategy":"validation","validationCode":"def build_client(cfg):\n    missing = [k for k in (\"team_id\", \"agent_id\", \"user_id\") if not cfg.get(k)]\n    if missing:\n        raise ValueError(f\"missing config: {missing}\")\n    return MemoryClient(..., **{k: cfg[k] for k in (\"team_id\", \"agent_id\", \"user_id\")})","typeGuard":null,"tryCatchPattern":"try:\n    client = MemoryClient(...)\nexcept ParamError as e:\n    raise ConfigError(f\"client construction failed: {e}\") from e","preventionTips":["Fail fast at app startup if any of team_id/agent_id/user_id env vars are empty","Centralize client construction in one factory with a config check","Use required env lookups (os.environ[...]) instead of .get with defaults","Document the isolation triple as mandatory for v3 in your onboarding docs"],"tags":["python","configuration","validation"],"backgroundTag":"missing-required-config","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}