mihomo-party-org/clash-party · error
Failed to parse profile "${id}": ${msg}
Error message
Failed to parse profile "${id}": ${msg} What it means
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.
Source
Thrown at src/main/config/profile.ts:631
const trimmed = profile.trim()
if (
trimmed.startsWith('<!DOCTYPE') ||
trimmed.startsWith('<html') ||
trimmed.startsWith('<HTML') ||
/<style[^>]*>/i.test(trimmed.slice(0, 500))
) {
throw new Error(
`Profile "${id}" contains HTML instead of YAML. The subscription may have returned an error page. Please re-import or update the subscription.`
)
}
try {
let result = parse(profile)
if (typeof result !== 'object') result = {}
return result as IMihomoConfig
} catch (e) {
const msg = e instanceof Error ? e.message : String(e)
throw new Error(`Failed to parse profile "${id}": ${msg}`)
}
}
// attachment;filename=xxx.yaml; filename*=UTF-8''%xx%xx%xx
function parseFilename(str: string): string {
if (str.match(/filename\*=.*''/)) {
const parts = str.split(/filename\*=.*''/)
if (parts[1]) {
return decodeURIComponent(parts[1])
}
}
const parts = str.split('filename=')
if (parts[1]) {
return parts[1].replace(/^["']|["']$/g, '')
}
return 'Remote File'
}
View on GitHub (pinned to 911e090537)
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.
Example fix
// before (profile content) proxies: - name: a # tab indent -> parse error // after proxies: - name: a # spaces
Defensive patterns
Strategy: try-catch
Validate before calling
try {
YAML.parse(content)
} catch (e) {
console.error(`profile YAML invalid: ${e.message}`) // fix before loading
} Try / catch
try {
const cfg = await getProfile(id)
} catch (e) {
const m = e.message.match(/Failed to parse profile "([^"]+)": (.*)/)
if (m) {
const [, profileId, yamlError] = m
console.error(`fix YAML in ${profileId}: ${yamlError}`)
}
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Profile "${id}" contains HTML instead of YAML. The subscript
- Subscription failed: Profile is not a valid YAML
- Subscription failed: Profile missing proxies or providers
- Empty URL
- ${i18next.t('mihomo.error.profileCheckFailed')}: ${allLines.
AI-assisted analysis of mihomo-party-org/clash-party@911e090537 (2026-08-30).
Data as JSON: /api/errors/b6871c582fc956cb.
Report an issue: GitHub.