MetaCubeX/mihomo · error · InvalidParams
Invalid parameters: {detail}
Error message
Invalid parameters: {detail} What it means
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.
Source
Thrown at mihomo/client.py:90
"""
url = self.BASE_URL + "/" + str(uid)
params.update({"lang": language.value})
async with aiohttp.ClientSession() as session:
async with session.get(url, params=params) as response:
match response.status:
case 200:
return await response.json(encoding="utf-8")
case 400:
try:
data = await response.json(encoding="utf-8")
except:
raise InvalidParams()
else:
if isinstance(data, dict) and (
detail := data.get("detail")
):
raise InvalidParams(detail)
raise InvalidParams()
case 404:
raise UserNotFound()
case _:
raise HttpRequestError(response.status, str(response.reason))
async def fetch_user(
self,
uid: int,
*,
replace_icon_name_with_url: bool = False,
) -> StarrailInfoParsed:
"""
Fetches user data from the API.
Args:
- uid (`int`): The user ID.
- replace_icon_name_with_url (`bool`): Whether to replace icon names with asset URLs.View on GitHub (pinned to 008b91bfe8)
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.
Example fix
// before client = MihomoAPI(language=Language.CHT) data = await client.fetch_user_v1(1234567890) # 10-digit account id -> 400 detail // after client = MihomoAPI(language=Language.CHT) data = await client.fetch_user_v1(100000001) # correct 9-digit UID
Defensive patterns
Strategy: try-catch
Validate before calling
from mihomo import Language
assert isinstance(lang, Language) and lang.value in {l.value for l in Language}
assert str(uid).isdigit() and len(str(uid)) == 9 Try / catch
from mihomo.errors import InvalidParams
try:
data = await client.fetch_user(uid)
except InvalidParams as e:
detail = e.message # e.g. 'Invalid parameters: invalid uid'
# branch on the detail substring to tell the user what to fix Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of MetaCubeX/mihomo@008b91bfe8 (2026-08-27).
Data as JSON: /api/errors/ba8d5e8f57f03c40.
Report an issue: GitHub.