{"record":{"id":"e3bceb0d9ae63167","repo":"RayWangQvQ/BiliBiliToolPro","slug":"cookie","errorCode":null,"errorMessage":"Cookie字符串格式异常，内部无等号","messagePattern":"Cookie字符串格式异常，内部无等号","errorType":"validation","errorClass":"BiliValidationException","httpStatus":null,"severity":"error","filePath":"src/Ray.BiliBiliTool.Agent/BiliCookie.cs","lineNumber":72,"sourceCode":"    [Description(\"buvid3\")]\n    public string Buvid =>\n        CookieItemDictionary.TryGetValue(GetPropertyDescription(nameof(Buvid)), out string? buvid)\n            ? buvid\n            : \"\";\n\n    #endregion\n\n\n    /// <summary>\n    /// 检查是否已配置\n    /// </summary>\n    /// <returns></returns>\n    public override void Check()\n    {\n        base.Check();\n\n        if (CookieItemDictionary.Count == 0)\n            throw new BiliValidationException(\"Cookie字符串格式异常，内部无等号\");\n\n        bool result = true;\n        string msg = \"Cookie字符串异常，无[{0}]项\";\n\n        //UserId为空，抛异常\n        if (string.IsNullOrWhiteSpace(UserId))\n        {\n            throw new BiliValidationException(\n                string.Format(msg, GetPropertyDescription(nameof(UserId)))\n            );\n        }\n        else if (!long.TryParse(UserId, out long uid)) //不为空，但不能转换为long，警告\n        {\n            throw new BiliValidationException(\n                string.Format(\n                    \"[{0}]={1} 不能转换为long型，请确认配置的是正确的Cookie值\",\n                    GetPropertyDescription(nameof(UserId)),\n                    UserId","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/RayWangQvQ/BiliBiliToolPro/blob/c599b2c0da964e16ea8c454397aa07bb16212628/src/Ray.BiliBiliTool.Agent/BiliCookie.cs#L54-L90","documentation":"BiliCookie.Check validates that the cookie string was parsed into key=value items; if CookieItemDictionary is empty, no '=' was present anywhere in the configured cookie string, so it throws BiliValidationException. It fails fast before any API call is made with an unusable cookie.","triggerScenarios":"Constructing a BiliCookie from a string with no '=' characters (e.g. a raw token, a placeholder like 'xxxx', or whitespace) and calling Check(); tests deliberately pass an empty dictionary.","commonSituations":"User pastes only the value of SESSDATA instead of the full 'SESSDATA=...; bili_jct=...' string; cookie copied with URL-encoding stripped of '='; config env var left as a dummy value.","solutions":["Copy the full cookie string from browser devtools (Application > Cookies), including every 'key=value' pair separated by '; '.","Ensure '=' characters are not stripped or double-encoded in your config source (appsettings.json, env var, CI secret).","Validate the cookie string contains at least one '=' before constructing BiliCookie."],"exampleFix":"// before\nvar cookie = new BiliCookie(\"abc123def456\");\n// after\nvar cookie = new BiliCookie(\"SESSDATA=abc123def456; bili_jct=xyz; DedeUserID=12345\");","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(cookieString) || !cookieString.Contains('='))\n    throw new ArgumentException(\"Cookie string must contain key=value pairs separated by ';'\");","typeGuard":null,"tryCatchPattern":"try { cookie.Check(); }\ncatch (BiliValidationException ex) { logger.LogError(\"Cookie 配置无效: {Msg}\", ex.Message); return; }","preventionTips":["Always copy the full cookie string including '=' from browser devtools.","Call Check() immediately after constructing BiliCookie to fail fast.","Avoid hand-typing cookie values; paste them verbatim."],"tags":["csharp","cookie","config","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"c599b2c0da964e16ea8c454397aa07bb16212628","analyzedAt":"2026-09-12T09:48:04.090Z","contentChangedAt":"2026-09-12T09:48:04.090Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}