{"record":{"id":"59d530b50fb195f6","repo":"RayWangQvQ/BiliBiliToolPro","slug":"qlenvlist-tojsonstr","errorCode":null,"errorMessage":"查询环境变量失败：{qlEnvList.ToJsonStr()}","messagePattern":"查询环境变量失败：(.+?)","errorType":"exception","errorClass":"BiliIntegrationException","httpStatus":null,"severity":"error","filePath":"src/Ray.BiliBiliTool.DomainService/LoginDomainService.cs","lineNumber":252,"sourceCode":"    }\n\n    public async Task<bool> SaveCookieToQinLongAsync(\n        BiliCookie ckInfo,\n        CancellationToken cancellationToken\n    )\n    {\n        try\n        {\n            var token = await GetQingLongAuthTokenAsync();\n            if (string.IsNullOrEmpty(token))\n            {\n                throw new BiliIntegrationException(\"获取青龙token失败\");\n            }\n\n            var qlEnvList = await qingLongApi.GetEnvsAsync(\"Ray_BiliBiliCookies__\", token);\n            if (qlEnvList.Code != 200)\n            {\n                throw new BiliIntegrationException($\"查询环境变量失败：{qlEnvList.ToJsonStr()}\");\n            }\n\n            logger.LogDebug(qlEnvList.Data.ToJsonStr());\n            logger.LogDebug(ckInfo.ToString());\n\n            var list = qlEnvList\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(\"用户已存在，更新cookie\");\n                logger.LogInformation(\"Key：{key}\", oldEnv.name);\n                var update = new UpdateQingLongEnv\n                {\n                    id = oldEnv.id,\n                    name = oldEnv.name,","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/RayWangQvQ/BiliBiliToolPro/blob/c599b2c0da964e16ea8c454397aa07bb16212628/src/Ray.BiliBiliTool.DomainService/LoginDomainService.cs#L234-L270","documentation":"Thrown by SaveCookieToQinLongAsync when the QingLong GetEnvsAsync call returns a Code other than 200, meaning the environment-variable list query against the QingLong panel failed. The exception includes the full serialized response so the caller can see the panel's error message.","triggerScenarios":"qingLongApi.GetEnvsAsync(\"Ray_BiliBiliCookies__\", token) responds with Code != 200 — invalid/expired token, QingLong app lacking env read permission, or the panel returning an error envelope (auth failure, panel down).","commonSituations":"QingLong token expired between obtaining and using it; the QingLong application was created without environment-variable permissions; QingLong panel upgraded and the open API path/response changed.","solutions":["Read the serialized response in the exception to identify the panel's error (usually auth or permission related).","Regenerate the QingLong app's ClientSecret and update configuration.","Grant the QingLong application env read/write permissions in the panel's app settings.","Verify the QingLong panel version supports the open API endpoint used."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    await loginDomainService.SaveCookieToQinLongAsync(ck);\n}\ncatch (BiliIntegrationException ex) when (ex.Message.Contains(\"查询环境变量失败\"))\n{\n    logger.LogError(\"青龙环境变量查询失败（多为token/权限问题）：{msg}\", ex.Message);\n    // fix credentials in QingLong panel then re-run\n}","preventionTips":["Ensure the QingLong app has environment-variable permissions.","Keep ClientSecret in sync after regenerating it in the panel.","Confirm panel version compatibility with the open API used."],"tags":["qinglong","api-error-response","environment-variables","permissions"],"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"}