{"record":{"id":"b6871c582fc956cb","repo":"mihomo-party-org/clash-party","slug":"failed-to-parse-profile-id-msg","errorCode":null,"errorMessage":"Failed to parse profile \"${id}\": ${msg}","messagePattern":"Failed to parse profile \"(.+?)\": (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/config/profile.ts","lineNumber":631,"sourceCode":"  const trimmed = profile.trim()\n  if (\n    trimmed.startsWith('<!DOCTYPE') ||\n    trimmed.startsWith('<html') ||\n    trimmed.startsWith('<HTML') ||\n    /<style[^>]*>/i.test(trimmed.slice(0, 500))\n  ) {\n    throw new Error(\n      `Profile \"${id}\" contains HTML instead of YAML. The subscription may have returned an error page. Please re-import or update the subscription.`\n    )\n  }\n\n  try {\n    let result = parse(profile)\n    if (typeof result !== 'object') result = {}\n    return result as IMihomoConfig\n  } catch (e) {\n    const msg = e instanceof Error ? e.message : String(e)\n    throw new Error(`Failed to parse profile \"${id}\": ${msg}`)\n  }\n}\n\n// attachment;filename=xxx.yaml; filename*=UTF-8''%xx%xx%xx\nfunction parseFilename(str: string): string {\n  if (str.match(/filename\\*=.*''/)) {\n    const parts = str.split(/filename\\*=.*''/)\n    if (parts[1]) {\n      return decodeURIComponent(parts[1])\n    }\n  }\n  const parts = str.split('filename=')\n  if (parts[1]) {\n    return parts[1].replace(/^[\"']|[\"']$/g, '')\n  }\n  return 'Remote File'\n}\n","sourceCodeStart":613,"sourceCodeEnd":649,"githubUrl":"https://github.com/mihomo-party-org/clash-party/blob/911e090537acdf7c50bee1c3aebecc2ef119a8b5/src/main/config/profile.ts#L613-L649","documentation":"parseProfileContent runs the profile text through a YAML parser; any parser exception is wrapped as `Failed to parse profile \"<id>\": <underlying message>`. The wrapper preserves the YAML parser's diagnostic while identifying which stored profile is malformed.","triggerScenarios":"baseProfile or getProfile parses a profile whose content is neither valid YAML nor HTML — the `parse` call throws (bad indentation, tabs, invalid syntax, wrong format like JSON5/Surge config).","commonSituations":"Manually edited YAML with tab characters or wrong indentation; profile saved from a non-Clash client format (Surge/Quantumult ini); truncated download; binary garbage from wrong encryption key.","solutions":["Read the wrapped underlying message to locate the YAML syntax problem (line/column usually included).","Open the profile file and fix indentation/tabs — YAML forbids tabs for indentation.","Re-import the subscription to replace corrupted or truncated content.","Convert the config to Clash/mihomo YAML format if it came from another client."],"exampleFix":"// before (profile content)\nproxies:\n\t- name: a   # tab indent -> parse error\n// after\nproxies:\n  - name: a   # spaces","handlingStrategy":"try-catch","validationCode":"try {\n  YAML.parse(content)\n} catch (e) {\n  console.error(`profile YAML invalid: ${e.message}`) // fix before loading\n}","typeGuard":null,"tryCatchPattern":"try {\n  const cfg = await getProfile(id)\n} catch (e) {\n  const m = e.message.match(/Failed to parse profile \"([^\"]+)\": (.*)/)\n  if (m) {\n    const [, profileId, yamlError] = m\n    console.error(`fix YAML in ${profileId}: ${yamlError}`)\n  }\n}","preventionTips":["Lint edited profile YAML with a YAML linter before saving.","Never use tab characters for YAML indentation.","Re-import the subscription after any truncated or corrupted download."],"tags":["yaml","parse-error","profile"],"backgroundTag":"yaml-syntax-error","analyzedSha":"911e090537acdf7c50bee1c3aebecc2ef119a8b5","analyzedAt":"2026-08-30T13:00:49.174Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}