rtk-ai/rtk · error · anyhow::Error

Filter file present but not valid TOML — see the error above

Error message

Filter file present but not valid TOML — see the error above.

What it means

`rtk trust` walks .rtk/filters.toml and ~/.config/rtk/filters.toml and parses each file before trusting it. If a file exists but filter_parse_error reports a TOML syntax error (printed per-file above with the file path and error), the run ends with this summary bail — unparseable filters are never trusted, even with --yes.

Source

Thrown at src/hooks/trust.rs:309

            continue;
        }

        print_filter_notice(&filter_path, scope, &filters);
        print_risk_summary(&content);

        if !(yes || confirm_enable_at_tty()?) {
            eprintln!("  Not enabled — re-run `rtk trust --yes` to trust non-interactively.");
            continue;
        }
        let hash = crate::hooks::integrity::compute_hash_bytes(&bytes);
        trust_filter_with_hash(&filter_path, &hash)?;
        enabled_any = true;
        eprintln!("  Enabled — revoke with `rtk untrust`.");
    }

    if !found_any {
        if had_error {
            anyhow::bail!("Filter file present but not valid TOML — see the error above.");
        }
        anyhow::bail!("No custom filters found (.rtk/filters.toml or ~/.config/rtk/filters.toml)");
    }
    if !enabled_any {
        if !interactive {
            anyhow::bail!("Custom filters found but none enabled — re-run `rtk trust --yes`.");
        }
        return Ok(());
    }
    println!("Filters will now be applied.");
    Ok(())
}

pub fn print_filter_notice(path: &Path, scope: &str, filters: &[(String, String)]) {
    let yellow = "\x1b[33m";
    let reset = "\x1b[0m";
    eprintln!();
    eprintln!(

View on GitHub (pinned to d977e1c316)

Solutions

  1. Read the per-file parse error printed above the bail — it names the file and the TOML position
  2. Lint before trusting: `python3 -c 'import tomllib,sys; tomllib.load(open(sys.argv[1],"rb"))' .rtk/filters.toml`
  3. Fix the syntax, then re-run `rtk trust --yes`

Example fix

# .rtk/filters.toml before
[[filters]]
name = "make"
match_command = ^make\b    # unquoted regex → TOML error

# after
[[filters]]
name = "make"
match_command = "^make\\b"
Defensive patterns

Strategy: validation

Validate before calling

# bash/CI: validate TOML syntax before running rtk trust
python3 -c 'import tomllib,sys; tomllib.load(open(sys.argv[1],"rb"))' .rtk/filters.toml \
  || { echo 'invalid TOML — fix before trust' >&2; exit 1; }
rtk trust --yes

Prevention

When it happens

Trigger: A filters.toml with syntax errors (unquoted strings, wrong table headers, stray brackets, bad escapes) when running `rtk trust` or `rtk trust --yes`; had_error is set at src/hooks/trust.rs:271, the bail lands at :309.

Common situations: Hand-editing filters with YAML habits; partial writes from an editor crash; filters generated by scripts with unescaped user input.

Related errors


AI-assisted analysis of rtk-ai/rtk@d977e1c316 (2026-08-16). Data as JSON: /api/errors/02a94dd63e32ca00. Report an issue: GitHub.