RayWangQvQ/BiliBiliToolPro · error · BiliValidationException
请正确配置Cookie后再运行,配置方式见
Error message
请正确配置Cookie后再运行,配置方式见 {Config.Constants.SourceCodeUrl} What it means
Final fallback in Check: if any secondary validation set result=false, the library throws BiliValidationException pointing to the project's documentation URL (Config.Constants.SourceCodeUrl) so users know how to configure the cookie properly.
Solutions
- Follow the configuration guide at the URL in the message (project source README) to build the cookie correctly.
- Re-export all cookies fresh from a logged-in browser session.
- If the cookie was recently valid, re-login to bilibili — logging out invalidates SESSDATA/bili_jct.
Example fix
// before (placeholder config) "BiliCookie": "your cookie here" // after "BiliCookie": "DedeUserID=12345; SESSDATA=abc%2Cdef; bili_jct=6789token"
Defensive patterns
Strategy: validation
Validate before calling
var required = new[] { "DedeUserID", "SESSDATA", "bili_jct" };
var ok = required.All(k => cookieString.Split(';').Any(p => p.TrimStart().StartsWith(k + "=")));
if (!ok) throw new ArgumentException("Cookie 配置不完整,参见项目 README"); Try / catch
try { cookie.Check(); }
catch (BiliValidationException ex) { logger.LogError("请按文档配置 Cookie: {Msg}", ex.Message); } Prevention
- Follow the README cookie configuration guide on first setup.
- Re-export the whole cookie after any bilibili re-login.
- Store the cookie as one verbatim string in a single config field.
When it happens
Trigger: Any Check() path that accumulates validation failures (result=false) without one of the earlier specific throws, e.g. other invalid cookie item values flagged during aggregate validation.
Common situations: First-time setup with an incorrectly formatted or incomplete cookie; users skipping the README cookie configuration instructions; expired/regenerated cookies after password change or logout.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Cookie字符串格式异常,内部无等号
- Cookie字符串异常,无[ ]项
- [ ]= 不能转换为long型,请确认配置的是正确的Cookie值
- Unsupported algorithm
- 登录失败,请检查Cookie
AI-assisted analysis of RayWangQvQ/BiliBiliToolPro@c599b2c0da (2026-09-12).
Data as JSON: /api/errors/c14be9b7b0e98a61.
Report an issue: GitHub.
Appendix: source
Thrown at src/Ray.BiliBiliTool.Agent/BiliCookie.cs:112
//SessData为空,抛异常
if (string.IsNullOrWhiteSpace(SessData))
{
throw new BiliValidationException(
string.Format(msg, GetPropertyDescription(nameof(SessData)))
);
}
//BiliJct为空,抛异常
if (string.IsNullOrWhiteSpace(BiliJct))
{
throw new BiliValidationException(
string.Format(msg, GetPropertyDescription(nameof(BiliJct)))
);
}
if (!result)
throw new BiliValidationException(
$"请正确配置Cookie后再运行,配置方式见 {Config.Constants.SourceCodeUrl}"
);
}
private string GetPropertyDescription(string propertyName)
{
return GetType().GetPropertyDescription(propertyName);
}
}
View on GitHub (pinned to c599b2c0da)