{"record":{"id":"6bdeb81405d2b729","repo":"libnyanpasu/clash-nyanpasu","slug":"profiles-yaml-failed-validation-errors","errorCode":null,"errorMessage":"profiles.yaml failed validation: {errors:?}","messagePattern":"profiles\\.yaml failed validation: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/tauri/src/client/profiles.rs","lineNumber":60,"sourceCode":"            .assemble();\n        let manager = if should_load {\n            setup\n                .load()\n                .await\n                .context(\"failed to load profiles persistent state manager\")?\n        } else {\n            setup\n                .from_state(Profiles::default())\n                .await\n                .context(\"failed to initialize profiles persistent state manager\")?\n        };\n\n        manager\n            .snapshot_handle()\n            .load()\n            .state\n            .validate()\n            .map_err(|errors| anyhow::anyhow!(\"profiles.yaml failed validation: {errors:?}\"))?;\n\n        let actor_ref = Actor::spawn(\n            None,\n            ProfilesActor,\n            ProfilesActorArgs {\n                manager,\n                fs,\n                fetcher,\n                materialization,\n                notifier,\n            },\n        )\n        .await\n        .context(\"failed to spawn profiles actor\")?\n        .0;\n\n        Ok(Self {\n            inner: Arc::new(ProfilesClientInner { actor_ref }),","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/client/profiles.rs#L42-L78","documentation":"`ProfilesActor::new` validates the freshly loaded profiles.yaml snapshot (`state.validate()`) before spawning the actor; if validation returns errors, spawning is aborted with this anyhow error. It guarantees the actor never starts with an invalid profiles document. The `{errors:?}` payload lists every violated rule.","triggerScenarios":"Calling the profiles client bootstrap (which invokes `ProfilesActor::new` at backend/tauri/src/client/profiles.rs:60) after the profiles.yaml file on disk was edited by hand, merged incorrectly, downgraded by an older app version, or corrupted.","commonSituations":"Manual edits to profiles.yaml removing required fields (e.g. a chain item without a uid/name), schema drift after upgrading the app so old files no longer validate, a failed subscription import writing malformed entries, or concurrent writes producing a partially-written file.","solutions":["Read the `{errors:?}` list and fix the corresponding fields in profiles.yaml (or via the UI editor)","Restore profiles.yaml from a backup or re-import the subscription to regenerate a valid file","If caused by a version downgrade, upgrade the app again or run the config migration to bring the file up to the current schema","Delete the invalid profiles.yaml so the app regenerates a default, then re-add profiles"],"exampleFix":"// before (profiles.yaml)\nitems:\n  - type: remote\n    url: not-a-valid-url\n// after\nitems:\n  - type: remote\n    name: my-sub\n    url: https://example.com/profile.yaml\n    updated: 1700000000","handlingStrategy":"validation","validationCode":"// Validate the profiles document before writing it to profiles.yaml\nif let Err(errors) = profiles_state.validate() {\n    eprintln!(\"refusing to save invalid profiles.yaml: {errors:?}\");\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"profiles.yaml failed validation\") => {\n        // back up the file, show validation errors to the user, offer restore-from-backup\n    }\n    Err(e) => return Err(e),\n    Ok(v) => v,\n}","preventionTips":["Validate profiles through the app's editor/API instead of hand-editing profiles.yaml","Keep a backup of the last known-good profiles.yaml","Run validation before saving any programmatic modification","Beware schema changes when downgrading app versions"],"tags":["validation","config","profiles","schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}