RayWangQvQ/BiliBiliToolPro · error · BiliBusinessException

re.ToJsonStr()

Error message

re.ToJsonStr()

What it means

SignAsync performs the daily VIP check-in via Sign2Async. On a non-zero API code it throws BiliBusinessException containing the full response JSON (re.ToJsonStr()). The check-in endpoint requires valid login cookies; failures are almost always authentication or risk-control responses from Bilibili.

Solutions

  1. Refresh the BiliBiliCookies config value with a newly exported cookie.
  2. Read the JSON in the exception message for the upstream code/message (-101 => re-login, -412 => reduce frequency/change IP).
  3. Ensure only one instance of the scheduled tool runs per account.
  4. Catch BiliBusinessException around sign tasks so other daily tasks still execute.

Example fix

// before
await vipBigPointService.SignAsync(dailyTaskInfo, ck);
// after
try { await vipBigPointService.SignAsync(dailyTaskInfo, ck); }
catch (BiliBusinessException ex)
{
    logger.LogWarning("大会员签到失败: {Msg}", ex.Message);
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (string.IsNullOrWhiteSpace(ck.Sessdata) || string.IsNullOrWhiteSpace(ck.BiliJct))
    logger.LogWarning("Cookie不完整,签到大概率失败");

Try / catch

try { await svc.SignAsync(info, ck); }
catch (BiliBusinessException ex)
{
    logger.LogWarning("签到失败: {Msg}", ex.Message);
}

Prevention

When it happens

Trigger: Expired SESSDATA/bili_jct in the cookie, Bilibili returning -101 (not logged in) or -412 (risk control) for the sign endpoint, or calling sign twice in a day if the API rejects duplicate signs with an error code.

Common situations: Daily cron run with a stale cookie; account flagged by anti-bot after frequent requests; multiple instances of the tool signing with the same account causing conflicts.

Related errors


AI-assisted analysis of RayWangQvQ/BiliBiliToolPro@c599b2c0da (2026-09-12). Data as JSON: /api/errors/2f41f3c5f651de04. Report an issue: GitHub.

Appendix: source

Thrown at src/Ray.BiliBiliTool.DomainService/VipBigPointDomainService.cs:117

    {
        var signInfo = await apiApi.GetThreeDaySignAsync(
            new ThreeDaySignRequest { csrf = ck.BiliJct },
            ck.ToString()
        );
        if (signInfo.Data.three_day_sign.signed)
        {
            logger.LogInformation("已完成,跳过");
            logger.LogInformation(signInfo.Data.ToString());
            return;
        }

        BiliApiResponse<Sign2Response> re = await apiApi.Sign2Async(
            new Sign2RequestPath(ck.BiliJct),
            new Sign2Request(),
            ck.ToString()
        );
        if (re.Code != 0)
            throw new BiliBusinessException(re.ToJsonStr());

        logger.LogInformation("签到成功");
        logger.LogInformation(re.Data.ToString());

        signInfo = await apiApi.GetThreeDaySignAsync(
            new ThreeDaySignRequest { csrf = ck.BiliJct },
            ck.ToString()
        );
        signInfo.Data.LogPointInfo(logger);
    }

    /// <summary>
    /// 领取任务
    /// </summary>
    /// <param name="combine"></param>
    /// <param name="ck"></param>
    public async Task ReceiveDailyMissionsAsync(VipBigPointCombine combine, BiliCookie ck)
    {

View on GitHub (pinned to c599b2c0da)