{"record":{"id":"a53d6a598d5ea18b","repo":"koala73/worldmonitor","slug":"get-needs-a-host-relative-api-path-starting-with","errorCode":null,"errorMessage":"get() needs a host-relative API path starting with '/'","messagePattern":"get\\(\\) needs a host-relative API path starting with '/'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdk/python/src/worldmonitor_sdk/__init__.py","lineNumber":194,"sourceCode":"        args.update(kwargs)\n        return self._rpc(\"tools/call\", {\"name\": name, \"arguments\": args})\n\n    def list_tools(self):\n        \"\"\"List every MCP tool (public - no key needed).\"\"\"\n        return self._rpc(\"tools/list\")\n\n    def list_prompts(self):\n        \"\"\"List MCP prompt templates (public).\"\"\"\n        return self._rpc(\"prompts/list\")\n\n    def list_resources(self):\n        \"\"\"List MCP resources (public).\"\"\"\n        return self._rpc(\"resources/list\")\n\n    def get(self, path, params=None, **kwargs):\n        \"\"\"GET a raw REST path (host-relative, e.g. ``/api/health``).\"\"\"\n        if not path.startswith(\"/\"):\n            raise ValueError(\"get() needs a host-relative API path starting with '/'\")\n        query = dict(params or {})\n        query.update(kwargs)\n        url = self.base_url + path\n        if query:\n            url += \"?\" + urllib.parse.urlencode({k: _stringify(v) for k, v in query.items()})\n        status, content_type, text = self._transport(\n            {\"url\": url, \"method\": \"GET\", \"headers\": self._headers(accept=\"application/json\")},\n            self.timeout,\n        )\n        value = parse_body(text, content_type)\n        if status < 200 or status >= 300:\n            raise APIError(status, value)\n        return value\n\n    def health(self):\n        \"\"\"API status / health check.\"\"\"\n        return self.get(\"/api/health\")\n","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/koala73/worldmonitor/blob/ffec79ac339946fd2d24e85845da5755dcaa534b/sdk/python/src/worldmonitor_sdk/__init__.py#L176-L212","documentation":"The Python SDK `Client.get()` requires a host-relative REST path beginning with `/` (e.g. `/api/health`). Paths without a leading slash are rejected before any network call, because the method concatenates `base_url + path` and a missing slash would silently produce a wrong URL. Use the curated helper `health()` for the common case.","triggerScenarios":"Calling `client.get(\"api/health\")` or any path lacking a leading `/`; passing a path copied from docs that omitted the slash.","commonSituations":"Copy/pasting a path from documentation that renders without the leading slash; constructing the path dynamically without ensuring a `/` prefix.","solutions":["Prefix the path with `/`: `client.get(\"/api/health\")`","Use `client.health()` for the health endpoint, which supplies the path correctly","Normalize programmatically: `path = '/' + path.lstrip('/')`"],"exampleFix":"# before\nclient.get(\"api/health\")\n# after\nclient.get(\"/api/health\")\n# or use the curated helper\nclient.health()","handlingStrategy":"validation","validationCode":"# Normalize the path before calling get().\npath = '/' + path.lstrip('/')\nif not path.startswith('/'):\n    raise ValueError('path must start with /')\nclient.get(path)","typeGuard":"def is_host_relative_path(path: str) -> bool:\n    return isinstance(path, str) and path.startswith('/')","tryCatchPattern":null,"preventionTips":["Always pass a leading '/' to get()","Prefer curated helpers like client.health() which supply correct paths","Normalize dynamically-built paths with '/' + path.lstrip('/')"],"tags":["python","sdk","validation","rest","url"],"backgroundTag":null,"analyzedSha":"ffec79ac339946fd2d24e85845da5755dcaa534b","analyzedAt":"2026-08-12T11:24:56.012Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}