libnyanpasu/clash-nyanpasu · error

profiles.yaml failed validation: {errors:?}

Error message

profiles.yaml failed validation: {errors:?}

What it means

`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.

Source

Thrown at backend/tauri/src/client/profiles.rs:60

            .assemble();
        let manager = if should_load {
            setup
                .load()
                .await
                .context("failed to load profiles persistent state manager")?
        } else {
            setup
                .from_state(Profiles::default())
                .await
                .context("failed to initialize profiles persistent state manager")?
        };

        manager
            .snapshot_handle()
            .load()
            .state
            .validate()
            .map_err(|errors| anyhow::anyhow!("profiles.yaml failed validation: {errors:?}"))?;

        let actor_ref = Actor::spawn(
            None,
            ProfilesActor,
            ProfilesActorArgs {
                manager,
                fs,
                fetcher,
                materialization,
                notifier,
            },
        )
        .await
        .context("failed to spawn profiles actor")?
        .0;

        Ok(Self {
            inner: Arc::new(ProfilesClientInner { actor_ref }),

View on GitHub (pinned to f7dbce2997)

Solutions

  1. Read the `{errors:?}` list and fix the corresponding fields in profiles.yaml (or via the UI editor)
  2. Restore profiles.yaml from a backup or re-import the subscription to regenerate a valid file
  3. If caused by a version downgrade, upgrade the app again or run the config migration to bring the file up to the current schema
  4. Delete the invalid profiles.yaml so the app regenerates a default, then re-add profiles

Example fix

// before (profiles.yaml)
items:
  - type: remote
    url: not-a-valid-url
// after
items:
  - type: remote
    name: my-sub
    url: https://example.com/profile.yaml
    updated: 1700000000
Defensive patterns

Strategy: validation

Validate before calling

// Validate the profiles document before writing it to profiles.yaml
if let Err(errors) = profiles_state.validate() {
    eprintln!("refusing to save invalid profiles.yaml: {errors:?}");
}

Try / catch

match result {
    Err(e) if e.to_string().contains("profiles.yaml failed validation") => {
        // back up the file, show validation errors to the user, offer restore-from-backup
    }
    Err(e) => return Err(e),
    Ok(v) => v,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of libnyanpasu/clash-nyanpasu@f7dbce2997 (2026-09-08). Data as JSON: /api/errors/6bdeb81405d2b729. Report an issue: GitHub.