{"record":{"id":"a877bcda4c695a42","repo":"yikart/AiToEarn","slug":"failed-to-fetch-url-response-status","errorCode":null,"errorMessage":"Failed to fetch ${url}: ${response.status}","messagePattern":"Failed to fetch (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"project/aitoearn-electron/server/src/app.service.ts","lineNumber":15,"sourceCode":"/*\n * @Author: nevin\n * @Date: 2025-03-01 19:27:26\n * @LastEditTime: 2025-03-19 15:41:06\n * @LastEditors: nevin\n * @Description: 应用\n */\nimport { Injectable } from '@nestjs/common';\nimport * as yaml from 'yaml';\n\nasync function parseYml(url: string): Promise<any> {\n  try {\n    const response = await fetch(url);\n    if (!response.ok) {\n      throw new Error(`Failed to fetch ${url}: ${response.status}`);\n    }\n    const text = await response.text();\n    return yaml.parse(text.replace(/\\\\/g, ''));\n  } catch (error) {\n    console.error(`YAML解析失败: ${url}`, error);\n    throw error;\n  }\n}\n\n@Injectable()\nexport class AppService {\n  async getDownUrl() {\n    const winYml = 'https://ylzsfile.yikart.cn/att/latest.yml';\n    const macYml = 'https://ylzsfile.yikart.cn/att/latest-mac.yml';\n\n    const [winYmlJson, macYmlJson] = await Promise.all([\n      parseYml(winYml),\n      parseYml(macYml),","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-electron/server/src/app.service.ts#L1-L33","documentation":"parseYml in the electron updater fetches a remote YAML update manifest and throws 'Failed to fetch ${url}: ${response.status}' when the HTTP response is not ok. The update-manifest endpoint returned a non-2xx status (404, 403, 500, etc.), so version metadata for win/mac could not be loaded.","triggerScenarios":"fetch(url) returns response.ok === false — the update YML URL points to a missing/renamed file, requires auth, is blocked by CDN/firewall, or the server errors.","commonSituations":"Latest.yml / latest-mac.yml missing on the release server after a deploy; wrong base URL or channel in update config; CDN geo-blocking; expired signed URLs returning 403.","solutions":["Open the exact URL in a browser/curl to confirm the status code and fix the hosted YML file or URL.","Check update channel configuration (version, channel, provider URL) matches the published artifacts.","Retry if the status is 5xx — it may be a transient server error.","Add a fallback update mirror or cached manifest."],"exampleFix":"// before\nconst response = await fetch(url);\nif (!response.ok) throw new Error(`Failed to fetch ${url}: ${response.status}`);\n// after\nconst response = await fetch(url);\nif (!response.ok) {\n  if (response.status >= 500 && attempt < 3) return retry(url, attempt + 1);\n  throw new Error(`Failed to fetch ${url}: ${response.status}`);\n}","handlingStrategy":"retry","validationCode":"const head = await fetch(url, { method: 'HEAD' });\nif (!head.ok) throw new Error(`更新清单不可用: ${url} -> ${head.status}`);","typeGuard":null,"tryCatchPattern":"try {\n  const yml = await parseYml(url);\n} catch (e) {\n  if (e.message.includes('404')) throw new Error('更新清单缺失，请检查发布产物 latest.yml');\n  if (e.message.includes('403')) throw new Error('更新清单被拒绝访问，请检查URL签名/权限');\n  throw e; // 5xx 可重试\n}","preventionTips":["Verify latest.yml / latest-mac.yml exist on the release server after each deploy.","Monitor the manifest URL with a HEAD request health check.","Keep a cached/fallback manifest mirror for resilience.","Match channel/provider config to the published artifact names."],"tags":["network","http","electron-updater","yaml"],"backgroundTag":"http-request-failed","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}