{"record":{"id":"75b77037567e5652","repo":"RayWangQvQ/BiliBiliToolPro","slug":"envlistre-msg","errorCode":null,"errorMessage":"查询白虎环境变量失败：{envListRe.Msg}","messagePattern":"查询白虎环境变量失败：(.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Ray.BiliBiliTool.DomainService/LoginDomainService.cs","lineNumber":421,"sourceCode":"    )\n    {\n        try\n        {\n            var token = baihuOptions.Value.Token;\n            if (string.IsNullOrEmpty(token))\n            {\n                throw new Exception(\"未配置白虎API Token\");\n            }\n\n            if (!token.StartsWith(\"Bearer \", StringComparison.OrdinalIgnoreCase))\n            {\n                token = $\"Bearer {token}\";\n            }\n\n            var envListRe = await baihuApi.GetEnvsAsync(token);\n            if (envListRe.Code != 200)\n            {\n                throw new Exception($\"查询白虎环境变量失败：{envListRe.Msg}\");\n            }\n\n            var list = envListRe\n                .Data.Where(x => x.Name.StartsWith(\"Ray_BiliBiliCookies__\"))\n                .ToList();\n            var oldEnv = list.FirstOrDefault(x => x.Value.Contains(ckInfo.UserId));\n\n            if (oldEnv != null)\n            {\n                logger.LogInformation(\"用户已存在，更新白虎环境变量\");\n                logger.LogInformation(\"Key：{key}\", oldEnv.Name);\n\n                oldEnv.Value = ckInfo.CookieStr;\n                oldEnv.Remark = string.IsNullOrEmpty(oldEnv.Remark)\n                    ? $\"bili-{ckInfo.UserId}\"\n                    : oldEnv.Remark;\n\n                var updateRe = await baihuApi.UpdateEnvAsync(oldEnv.Id, oldEnv, token);","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/RayWangQvQ/BiliBiliToolPro/blob/c599b2c0da964e16ea8c454397aa07bb16212628/src/Ray.BiliBiliTool.DomainService/LoginDomainService.cs#L403-L439","documentation":"Thrown by SaveCookieToBaihuAsync when the Baihu GetEnvsAsync call returns Code != 200, meaning the environment-variable listing request to the Baihu service failed. The exception includes the service's Msg field for diagnosis.","triggerScenarios":"baihuApi.GetEnvsAsync(token) responds with Code != 200 — invalid or expired bearer token, insufficient permissions on the Baihu account, or the Baihu service returning an error envelope.","commonSituations":"Baihu token revoked or rotated since configuration; token string pasted without/with wrong 'Bearer ' prefix (code auto-prefixes, double prefixes can also fail); Baihu service endpoint or API version changed.","solutions":["Read envListRe.Msg in the exception message to see the service's stated reason.","Regenerate the Baihu API token and update the Baihu:Token configuration.","Confirm the token has permission to list environment variables on the Baihu service.","Verify the Baihu API base URL and that the service is reachable."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-check token shape\nvar token = baihuOptions.Value.Token;\nif (string.IsNullOrWhiteSpace(token) || token.Length < 20)\n    throw new Exception(\"Baihu:Token 看起来无效，请重新生成\");","typeGuard":null,"tryCatchPattern":"try\n{\n    await loginDomainService.SaveCookieToBaihuAsync(ck);\n}\ncatch (Exception ex) when (ex.Message.Contains(\"查询白虎环境变量失败\"))\n{\n    logger.LogError(\"白虎环境变量查询失败，多为token失效：{msg}\", ex.Message);\n    // regenerate token and update config\n}","preventionTips":["Regenerate the Baihu token when it expires and update config promptly.","Don't double-prefix the token with 'Bearer ' — the code adds it if missing.","Confirm the Baihu account has env-listing permissions."],"tags":["baihu","api-error-response","auth-token","environment-variables"],"backgroundTag":"http-error-response","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"}