{"record":{"id":"ba8d5e8f57f03c40","repo":"MetaCubeX/mihomo","slug":"invalid-parameters-detail","errorCode":null,"errorMessage":"Invalid parameters: {detail}","messagePattern":"Invalid parameters: (.+?)","errorType":"exception","errorClass":"InvalidParams","httpStatus":400,"severity":"error","filePath":"mihomo/client.py","lineNumber":90,"sourceCode":"        \"\"\"\n        url = self.BASE_URL + \"/\" + str(uid)\n        params.update({\"lang\": language.value})\n\n        async with aiohttp.ClientSession() as session:\n            async with session.get(url, params=params) as response:\n                match response.status:\n                    case 200:\n                        return await response.json(encoding=\"utf-8\")\n                    case 400:\n                        try:\n                            data = await response.json(encoding=\"utf-8\")\n                        except:\n                            raise InvalidParams()\n                        else:\n                            if isinstance(data, dict) and (\n                                detail := data.get(\"detail\")\n                            ):\n                                raise InvalidParams(detail)\n                            raise InvalidParams()\n                    case 404:\n                        raise UserNotFound()\n                    case _:\n                        raise HttpRequestError(response.status, str(response.reason))\n\n    async def fetch_user(\n        self,\n        uid: int,\n        *,\n        replace_icon_name_with_url: bool = False,\n    ) -> StarrailInfoParsed:\n        \"\"\"\n        Fetches user data from the API.\n\n        Args:\n            - uid (`int`): The user ID.\n            - replace_icon_name_with_url (`bool`): Whether to replace icon names with asset URLs.","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/MetaCubeX/mihomo/blob/008b91bfe8c0e2daca0ab69061efd9ea1ad71bd2/mihomo/client.py#L72-L108","documentation":"InvalidParams(detail) is raised at mihomo/client.py:90 when the API returns HTTP 400 with a JSON body containing a 'detail' field; that detail text is embedded in the exception message ('Invalid parameters: {detail}'). It is the informative variant of the 400 handling in MihomoAPI.request and tells you exactly which parameter the mihomo API rejected. Both fetch_user and fetch_user_v1 funnel through request, so any bad parameter surfaces here.","triggerScenarios":"HTTP 400 from api.mihomo.me/sr_info_parsed/{uid} with a JSON body like {'detail': '...'} — caused by a non-existent/invalid UID format, an unsupported lang value in the query string, or an invalid version parameter on fetch_user_v1.","commonSituations":"Typos in hardcoded UIDs; locales the API dropped in a version update; migrating from another API wrapper (enka, mihomo predecessors) with different UID rules; detail strings such as 'invalid uid' or 'unsupported language' after the upstream contract changes.","solutions":["Read exc.message — the {detail} substring (e.g. 'Invalid parameters: invalid uid') names the exact offending parameter; fix it accordingly.","Ensure the UID is the 9-digit in-game Star Rail UID, not the account/HoYoverse ID.","Confirm your Language enum value is accepted by the current API; upgrade the mihomo package if it is out of date with the API's supported languages.","For fetch_user_v1, keep params to {'version': 'v1'} only — extra params are forwarded into the request and can trigger the 400."],"exampleFix":"// before\nclient = MihomoAPI(language=Language.CHT)\ndata = await client.fetch_user_v1(1234567890)  # 10-digit account id -> 400 detail\n\n// after\nclient = MihomoAPI(language=Language.CHT)\ndata = await client.fetch_user_v1(100000001)  # correct 9-digit UID","handlingStrategy":"try-catch","validationCode":"from mihomo import Language\n\nassert isinstance(lang, Language) and lang.value in {l.value for l in Language}\nassert str(uid).isdigit() and len(str(uid)) == 9","typeGuard":null,"tryCatchPattern":"from mihomo.errors import InvalidParams\ntry:\n    data = await client.fetch_user(uid)\nexcept InvalidParams as e:\n    detail = e.message  # e.g. 'Invalid parameters: invalid uid'\n    # branch on the detail substring to tell the user what to fix","preventionTips":["Log and surface e.message — the API's detail names the exact bad parameter.","Use the in-game 9-digit UID, never the HoYoverse account ID.","Pin a recent mihomo version so Language values match the live API.","Add unit tests that feed known-bad UIDs through your wrapper to assert a clean error path."],"tags":["python","mihomo","http-400","api-error-detail","star-rail"],"backgroundTag":"http-400-bad-request","analyzedSha":"008b91bfe8c0e2daca0ab69061efd9ea1ad71bd2","analyzedAt":"2026-08-27T19:16:11.578Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}