{"record":{"id":"7d75dcc59c44926c","repo":"rtk-ai/rtk","slug":"invalid-toml-not-loaded","errorCode":null,"errorMessage":"  {} — invalid TOML, not loaded: {}","messagePattern":"  (.+?) — invalid TOML, not loaded: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/hooks/trust.rs","lineNumber":273,"sourceCode":"        return Ok(());\n    }\n\n    let interactive = std::io::IsTerminal::is_terminal(&std::io::stdin());\n    let mut found_any = false;\n    let mut enabled_any = false;\n    let mut had_error = false;\n    for (scope, filter_path) in gated_filter_paths_labeled() {\n        if !filter_path.exists() {\n            continue;\n        }\n        let bytes = std::fs::read(&filter_path)\n            .with_context(|| format!(\"Failed to read {}\", filter_path.display()))?;\n        let content = String::from_utf8_lossy(&bytes);\n\n        if let Some(err) = crate::core::toml_filter::filter_parse_error(&content) {\n            had_error = true;\n            eprintln!(\n                \"  {} — invalid TOML, not loaded: {}\",\n                filter_path.display(),\n                err\n            );\n            continue;\n        }\n        let filters = crate::core::toml_filter::active_filter_summaries(&content);\n        if filters.is_empty() {\n            continue;\n        }\n        found_any = true;\n\n        if matches!(\n            check_trust(&filter_path).unwrap_or(TrustStatus::Untrusted),\n            TrustStatus::Trusted | TrustStatus::EnvOverride\n        ) {\n            eprintln!(\"  {} already trusted.\", filter_path.display());\n            enabled_any = true;\n            continue;","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/rtk-ai/rtk/blob/29f9bb7161775cd807565fd3041eb2b7d1be071c/src/hooks/trust.rs#L255-L291","documentation":"`rtk trust` (src/hooks/trust.rs:241) scans gated filter files — project `.rtk/filters.toml` and the global config-dir filters TOML (src/hooks/trust.rs:206-216) — parses each with `toml::from_str::<TomlFilterFile>` via `filter_parse_error` (src/core/toml_filter.rs:415), and prints `\"  {path} — invalid TOML, not loaded: {err}\"` to stderr when parsing fails. This is a warning, not a thrown error: the file is skipped (`continue`) with `had_error = true`, and the trust run proceeds with remaining files. The `{err}` is the `toml` crate's message and includes line/column and the expected-vs-found detail, so the text after the colon is the actual diagnostic to act on. The same parse gate protects `rtk` startup, so a file flagged here is inert everywhere until fixed.","triggerScenarios":"Running `rtk trust` (or `rtk trust --yes`) when `.rtk/filters.toml` or `~/.config/<data-dir>/filters.toml` contains TOML the `toml` crate rejects: syntax errors such as a missing closing quote or bracket, `key = value` with an unquoted string value, duplicate keys in one table, invalid inline-table/array syntax, or a wrong value type for a field of `TomlFilterFile`. Also triggered by leftover git merge-conflict markers (`<<<<<<<`/`>>>>>>>`), a UTF-8 BOM, or CRLF injected by a Windows editor — all surface as parse errors with a line number.","commonSituations":"Hand-editing `.rtk/filters.toml` to add a command filter and forgetting quotes around a glob/regex value; a teammate committing a filters file with smart quotes pasted from docs or chat; a botched merge leaving conflict markers; generating the file on Windows with CRLF; upgrading rtk to a version whose `TomlFilterFile` schema changed (renamed/retyped keys) so previously-valid TOML now fails deserialization. Users notice filters silently not applying, then see this line when running `rtk trust`.","solutions":["Run `rtk trust` and read the segment after `not loaded:` — the toml error gives the exact line/column (e.g. `expected `.`, `=`... at line 4 column 12`); open the named file at that position and fix the syntax (quote string values, close brackets/quotes, remove duplicate keys).","Check for non-syntax damage: merge-conflict markers (`<<<<<<<`), BOM at file start, and CRLF line endings (`file .rtk/filters.toml` or `cat -A`); strip them (`dos2unix`, resolve the merge) since each produces confusing parse positions.","Validate the file out-of-band before re-running: `python3 -c 'import tomllib;print(tomllib.load(open(\".rtk/filters.toml\",\"rb\")))'` or any TOML linter (taplo, `taplo fmt --check`) — syntax-valid but schema-wrong files need checking keys against the current rtk filters documentation (`rtk trust` output lists the active filter summaries it expects).","If the file was schema-valid on an older rtk, check the CHANGELOG/release notes for renamed filter keys, migrate the entries, then re-run `rtk trust` and confirm the file appears with its sha256 and trust prompt instead of the warning."],"exampleFix":"# before — .rtk/filters.toml (line 4 has an unquoted regex → invalid TOML, not loaded: expected `.`, `=` ...\n[filter.cargo-build]\ncommand = \"cargo build\"\npattern = ^warning: unused# missing quotes, `#` not a comment here\n\n# after\n[filter.cargo-build]\ncommand = \"cargo build\"\npattern = \"^warning: unused\"","handlingStrategy":"validation","validationCode":"# Before running `rtk trust`, syntax-check the gated files yourself:\npython3 - <<'EOF'\nimport tomllib, pathlib\nfor p in [pathlib.Path(\".rtk/filters.toml\"),\n          pathlib.Path.home()/\".config\"/\"rtk\"/\"filters.toml\"]:\n    if p.exists():\n        try:\n            tomllib.load(open(p, \"rb\"))\n            print(f\"OK   {p}\")\n        except Exception as e:\n            print(f\"FAIL {p}: {e}\")\nEOF\n# Or: taplo lint .rtk/filters.toml","typeGuard":null,"tryCatchPattern":"// In Rust tooling that writes filters.toml, validate round-trip before persisting:\nfn validate_filters_toml(content: &str) -> Result<(), toml::de::Error> {\n    toml::from_str::<TomlFilterFile>(content).map(|_| ())\n}\n// Write only after validation succeeds (atomic write, no partial file):\n// validate_filters_toml(&new_content)?; std::fs::write(&path, new_content)?;","preventionTips":["Quote every string value in filters.toml (patterns and globs especially — `^warn:`, `**/*.rs`, and values containing `#` or spaces must be quoted).","After any merge that touches .rtk/filters.toml, grep for conflict markers (`<<<<<<<`, `>>>>>>>`) and run `rtk trust` as a gate — it reports the first bad line with line/column.","Prefer LF line endings and no BOM (configure .gitattributes `*.toml text eol=lf`); BOM/CRLF from Windows editors are recurring causes of first-line parse errors.","When upgrading rtk, re-run `rtk trust` immediately; a schema change (renamed/retyped keys) shows up here as a deserialization error with the offending key named, before you depend on the filters."],"tags":["toml","config","rtk-trust","parse-error","filters-toml"],"backgroundTag":"toml-parse-error","analyzedSha":"29f9bb7161775cd807565fd3041eb2b7d1be071c","analyzedAt":"2026-08-20T15:54:42.457Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}