OdysseusYuan/LKY_OfficeTools · error · Exception
OfficeChannels_Url 信息获取失败!
Error message
OfficeChannels_Url 信息获取失败!
What it means
Thrown when the OfficeChannels_Url field cannot be extracted from AppJson.Info via Com_TextOS.GetCenterText. AppJson.Info is downloaded from a Gitee-hosted JSON release file and returns null on any network or HTTP failure. GetCenterText returns empty when its input is null or when the left/right markers are not found. So this fires either because AppJson.Info is null (network/Gitee unreachable) or because the JSON schema no longer contains the OfficeChannels_Url field in the expected format.
Source
Thrown at LKY_OfficeTools/Lib/Lib_OfficeInfo.cs:65
internal static string OfficeChannelInfo
{
get
{
try
{
//私有值非空判断
if (!string.IsNullOrWhiteSpace(_office_channel_info))
{
return _office_channel_info;
}
new Log("\n------> 正在获取 最新可用 Office 信息 ...", ConsoleColor.DarkCyan);
//获取频道信息,得到可用 Url 列表
string channel_info = Com_TextOS.GetCenterText(AppJson.Info, "\"OfficeChannels_Url\": \"", "\"");
if (string.IsNullOrEmpty(channel_info))
{
throw new Exception("OfficeChannels_Url 信息获取失败!");
}
List<string> channel_list = channel_info.Split(';').ToList();
//遍历获取有效地址,并下载channel信息
string office_info = null;
int try_times = 1; //尝试获取次数,初始值为1
foreach (var now_url in channel_list)
{
office_info = Com_WebOS.Visit_WebClient(now_url.Replace(" ", "")); //替换网址空格,并获得当前网址的访问信息
if (!string.IsNullOrEmpty(office_info))
{
new Log($" √ 已获得 Office 最新正版信息。", ConsoleColor.DarkGreen);
//info有值,返回该值。
return _office_channel_info = office_info;
}
//访问当前网址返回数据为空,或者无法截取获得有效字段时,遍历。View on GitHub (pinned to 6f9a1bd471)
Solutions
- Verify internet connectivity and that the Gitee release URL in Lib_AppInfo.cs is reachable from a browser.
- Inspect AppJson.Info content — if it is non-null but lacks OfficeChannels_Url, the upstream JSON schema changed; update the marker strings.
- Confirm the field uses the exact format `"OfficeChannels_Url": "url1;url2"` including the space after the colon.
- If behind a proxy, ensure WebClient picks up the system proxy / DefaultCredentials correctly.
- Retry after confirming Gitee is not rate-limiting the release download.
Example fix
// before
string channel_info = Com_TextOS.GetCenterText(AppJson.Info, "\"OfficeChannels_Url\": \"", "\"");
if (string.IsNullOrEmpty(channel_info))
{
throw new Exception("OfficeChannels_Url 信息获取失败!");
}
// after — separate network failure from schema mismatch
if (string.IsNullOrEmpty(AppJson.Info))
{
throw new Exception("AppJson.Info 为空,请检查网络或 Gitee 可达性。");
}
string channel_info = Com_TextOS.GetCenterText(AppJson.Info, "\"OfficeChannels_Url\": \"", "\"");
if (string.IsNullOrEmpty(channel_info))
{
throw new Exception("AppJson 中缺少 OfficeChannels_Url 字段,请检查 JSON 格式是否变更。");
} Defensive patterns
Strategy: validation
Validate before calling
// Check AppJson.Info before extracting channel URLs.
if (string.IsNullOrEmpty(AppJson.Info))
{
new Log("AppJson.Info 获取失败,请检查网络与 Gitee 可达性。", ConsoleColor.DarkRed);
return;
}
string channel_info = Com_TextOS.GetCenterText(AppJson.Info, "\"OfficeChannels_Url\": \"", "\"");
if (string.IsNullOrEmpty(channel_info))
{
new Log("AppJson 中缺少 OfficeChannels_Url 字段,JSON 格式可能已变更。", ConsoleColor.DarkRed);
return;
} Prevention
- Guard AppJson.Info with a null check before any GetCenterText call to distinguish network failure from schema drift.
- Pin and document the expected AppJson schema; alert on field changes.
- Add a connectivity health check for the Gitee release URL before the config fetch.
- Keep GetCenterText markers versioned alongside a sample of the expected JSON in tests.
When it happens
Trigger: AppJson.Info is null because Com_WebOS.Visit_WebClient failed to fetch the Gitee JSON (DNS error, connection refused, HTTP non-2xx, TLS failure, proxy block), OR the JSON was fetched but does not contain the marker `"OfficeChannels_Url": "` ... `"` in the expected quoting/spacing.
Common situations: No internet connection; Gitee is blocked or rate-limited; corporate firewall/proxy intercepts the request; the upstream JSON schema changed and dropped or renamed OfficeChannels_Url; the field's quoting changed (e.g., no space after colon).
Related errors
AI-assisted analysis of OdysseusYuan/LKY_OfficeTools@6f9a1bd471 (2026-08-13).
Data as JSON: /api/errors/9efb51b544caed41.
Report an issue: GitHub.