babalae/better-genshin-impact · error · Exception
前瞻直播数据异常
Error message
前瞻直播数据异常
What it means
A generic Exception from GetCodeMsgAsync thrown when an actId was resolved but GetLiveDataAsync returned an empty codeVer. The activity index responded (retcode 0, a live block exists) but the code_ver field is missing or empty, so the code-fetch step cannot proceed. This points to an unexpected/changed response shape rather than 'no activity'.
Source
Thrown at BetterGenshinImpact/GameTask/UseRedeemCode/GetLiveRedeemCode.cs:176
return result;
}
/// <summary>
/// 获取前瞻直播兑换码信息。返回格式:List[("奖励内容", "兑换码")]
/// </summary>
public async Task<List<RedeemCode>> GetCodeMsgAsync()
{
string actId = await GetActIdAsync("1");
if (string.IsNullOrEmpty(actId))
{
actId = await GetActIdAsync("2");
if (string.IsNullOrEmpty(actId))
throw new Exception("暂无前瞻直播资讯!");
}
var (codeVer, title) = await GetLiveDataAsync(actId);
if (string.IsNullOrEmpty(codeVer))
throw new Exception("前瞻直播数据异常");
var codeList = await GetCodeAsync(codeVer, actId);
return codeList;
}
}
View on GitHub (pinned to a7cb36712d)
Solutions
- Retry later once the codes are actually published (code_ver populated).
- Verify the JSON path data.live.code_ver still matches the upstream contract; update GetLiveDataAsync if it changed.
- Catch the exception and inform the user that livestream data is temporarily unavailable.
- Log the raw response (without secrets) once to confirm the shape.
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
var (codeVer, _) = await GetLiveDataAsync(actId);
if (string.IsNullOrEmpty(codeVer)) { /* data not published yet; retry later */ } Type guard
null
Try / catch
try { var codes = await svc.GetCodeMsgAsync(); }
catch (Exception ex) { Toast.Warning("前瞻直播数据异常,请稍后重试"); Log.Warning(ex.Message); } Prevention
- Retry once codes are actually published (codeVer populated).
- Confirm the data.live.code_ver path still matches upstream.
- Log the raw response shape once to detect schema drift.
When it happens
Trigger: GetLiveDataAsync returns a non-null live object whose code_ver is null/empty (the live entry exists but code_ver is not published yet), or the response JSON shape changed so code_ver is no longer under data.live.code_ver.
Common situations: The livestream was announced but redeem codes are not yet published (code_ver blank); an upstream API schema change moved/renamed code_ver; partial/malformed response cached or returned.
Related errors
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/61e3b72a8e383f48.
Report an issue: GitHub.