Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

config: attribute load errors to file vs env-var source (#2068)

Maximilian Roosd274af08b888
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 694446b08..c1a1dac06 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -99,6 +99,7 @@ pub use project::{
ProjectCiConfig, ProjectConfig, ProjectListConfig,
find_unknown_keys as find_unknown_project_keys, valid_project_config_keys,
};
+pub(crate) use user::LoadError;
pub use user::{
CommitConfig, CommitGenerationConfig, CopyIgnoredConfig, ListConfig, MergeConfig,
OverridableConfig, ResolvedConfig, StageMode, StepConfig, SwitchConfig, SwitchPickerConfig,
diff --git a/src/config/project.rs b/src/config/project.rs
index caf0bcf02..ac5c81e85 100644
--- a/src/config/project.rs
+++ b/src/config/project.rs
@@ -233,8 +233,12 @@ impl ProjectConfig {
);
}
- let config: ProjectConfig = toml::from_str(&contents)
- .map_err(|e| ConfigError::Message(format!("Failed to parse TOML: {}", e)))?;
+ let config: ProjectConfig = toml::from_str(&contents).map_err(|e| {
+ ConfigError::Message(format!(
+ "Project config at {} failed to parse:\n{e}",
+ crate::path::format_path_for_display(&config_path),
+ ))
+ })?;
Ok(Some(config))
}
diff --git a/src/config/user/mod.rs b/src/config/user/mod.rs
index 9bc7880e1..812151508 100644
--- a/src/config/user/mod.rs
+++ b/src/config/user/mod.rs
@@ -13,6 +13,8 @@ mod sections;
#[cfg(test)]
mod tests;
+use std::path::PathBuf;
+
use config::{Case, Config, ConfigError, File};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
@@ -31,6 +33,72 @@ pub use sections::{
UserProjectOverrides,
};
+/// Distinguishes *why* `UserConfig::load()` failed so callers can emit
+/// targeted diagnostics (file errors with line/col vs env-var attribution).
+#[derive(Debug)]
+pub enum LoadError {
+ /// A config file failed to parse. The `toml::de::Error` includes
+ /// line/column info and a source-snippet pointer.
+ File {
+ path: PathBuf,
+ label: &'static str,
+ err: Box<toml::de::Error>,
+ },
+ /// Config files parsed cleanly; applying env-var overrides failed.
+ /// `override_vars` lists `WORKTRUNK_*` env vars that could be the cause.
+ Env {
+ err: ConfigError,
+ override_vars: Vec<String>,
+ },
+ /// Other errors (validation, config-crate internals).
+ Other(ConfigError),
+}
+
+impl std::fmt::Display for LoadError {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ match self {
+ LoadError::File { path, label, err } => {
+ write!(
+ f,
+ "{label} at {} failed to parse:\n{err}",
+ crate::path::format_path_for_display(path)
+ )
+ }
+ LoadError::Env { err, .. } => write!(f, "{err}"),
+ LoadError::Other(err) => write!(f, "{err}"),
+ }
+ }
+}
+
+impl std::error::Error for LoadError {}
+
+/// Returns names of `WORKTRUNK_*` env vars that could be value overrides,
+/// excluding infrastructure paths and the `WORKTRUNK_TEST_` namespace.
+// TODO: This hardcoded exclusion list is a smell — ideally the config loading
+// layer would track which source each value came from, making attribution
+// automatic rather than heuristic. Consider integrating this into the config
+// crate's source-tracking or building our own env-var overlay.
+fn collect_worktrunk_override_vars() -> Vec<String> {
+ const INFRA_VARS: &[&str] = &[
+ "WORKTRUNK_CONFIG_PATH",
+ "WORKTRUNK_SYSTEM_CONFIG_PATH",
+ "WORKTRUNK_APPROVALS_PATH",
+ ];
+ let mut vars: Vec<String> = std::env::vars()
+ .filter_map(|(k, _)| {
+ if !k.starts_with("WORKTRUNK_") {
+ return None;
+ }
+ if INFRA_VARS.contains(&k.as_str()) || k.starts_with("WORKTRUNK_TEST_") {
+ return None;
+ }
+ Some(k)
+ })
+ .collect();
+ vars.sort();
+ vars
+}
+
/// User-level configuration for worktree path formatting and LLM integration.
///
/// This config is stored at `~/.config/worktrunk/config.toml` (or platform equivalent)
@@ -107,6 +175,14 @@ impl UserConfig {
/// 3. User config file (personal preferences)
/// 4. Environment variables (WORKTRUNK_*)
pub fn load() -> Result<Self, ConfigError> {
+ Self::load_with_cause().map_err(|e| ConfigError::Message(e.to_string()))
+ }
+
+ /// Like [`load()`](Self::load), but returns a [`LoadError`] that
+ /// distinguishes file-level parse failures (with line/col) from
+ /// env-var override failures. Used by `Repository::user_config()`
+ /// to emit targeted diagnostics.
+ pub(crate) fn load_with_cause() -> Result<Self, LoadError> {
// Note: worktree-path has no default set here - it's handled by the getter
// which returns the default when None. This allows us to distinguish
// "user explicitly set this" from "using default".
@@ -125,6 +201,28 @@ impl UserConfig {
// Feed migrated content to serde so deprecated patterns parse correctly
let migrated = super::deprecation::migrate_content(&content);
+
+ // Pre-validate with the toml crate for rich line/col errors.
+ // Try OverridableConfig first — it has section fields (list,
+ // commit, merge, ...) as direct fields, so toml tracks their
+ // location correctly. UserConfig's flatten loses field paths.
+ // Then try UserConfig to catch non-section fields (projects,
+ // skip-*-prompt) that OverridableConfig silently ignores.
+ if let Err(err) = toml::from_str::<OverridableConfig>(&migrated) {
+ return Err(LoadError::File {
+ path: system_path,
+ label: "System config",
+ err: Box::new(err),
+ });
+ }
+ if let Err(err) = toml::from_str::<Self>(&migrated) {
+ return Err(LoadError::File {
+ path: system_path,
+ label: "System config",
+ err: Box::new(err),
+ });
+ }
+
builder = builder.add_source(File::from_str(&migrated, config::FileFormat::Toml));
}
@@ -158,6 +256,23 @@ impl UserConfig {
"User config",
);
+ // Pre-validate with the toml crate for rich line/col errors
+ // (see system config comment above for the two-pass rationale).
+ if let Err(err) = toml::from_str::<OverridableConfig>(&migrated) {
+ return Err(LoadError::File {
+ path: config_path.clone(),
+ label: "User config",
+ err: Box::new(err),
+ });
+ }
+ if let Err(err) = toml::from_str::<Self>(&migrated) {
+ return Err(LoadError::File {
+ path: config_path.clone(),
+ label: "User config",
+ err: Box::new(err),
+ });
+ }
+
// Feed migrated content from check_and_migrate to serde so deprecated
// patterns parse correctly without reparsing the TOML here.
builder = builder.add_source(File::from_str(&migrated, config::FileFormat::Toml));
@@ -198,8 +313,20 @@ impl UserConfig {
// The config crate's `preserve_order` feature ensures TOML insertion order
// is preserved (uses IndexMap instead of HashMap internally).
// See: https://github.com/max-sixty/worktrunk/issues/737
- let config: Self = builder.build()?.try_deserialize()?;
- config.validate()?;
+ let config: Self = builder
+ .build()
+ .map_err(LoadError::Other)?
+ .try_deserialize()
+ .map_err(|err| {
+ // Files were pre-validated above, so a deserialize failure here
+ // is caused by env-var overrides.
+ LoadError::Env {
+ err,
+ override_vars: collect_worktrunk_override_vars(),
+ }
+ })?;
+
+ config.validate().map_err(LoadError::Other)?;
Ok(config)
}
diff --git a/src/config/user/tests.rs b/src/config/user/tests.rs
index 5d901f45c..550f8c812 100644
--- a/src/config/user/tests.rs
+++ b/src/config/user/tests.rs
@@ -2498,3 +2498,32 @@ fn test_reload_projects_from_permission_error() {
"Expected path in error, got: {err}"
);
}
+
+#[test]
+fn test_load_error_display_file() {
+ let toml_err = toml::from_str::<OverridableConfig>("[list]\nbranches = \"bad\"\n").unwrap_err();
+ let err = LoadError::File {
+ path: std::path::PathBuf::from("/tmp/config.toml"),
+ label: "User config",
+ err: Box::new(toml_err),
+ };
+ let msg = err.to_string();
+ assert!(msg.contains("User config at"), "{msg}");
+ assert!(msg.contains("failed to parse"), "{msg}");
+ assert!(msg.contains("line 2"), "{msg}");
+}
+
+#[test]
+fn test_load_error_display_env() {
+ let err = LoadError::Env {
+ err: config::ConfigError::Message("invalid type".into()),
+ override_vars: vec!["WORKTRUNK__LIST__BRANCHES".into()],
+ };
+ assert_eq!(err.to_string(), "invalid type");
+}
+
+#[test]
+fn test_load_error_display_other() {
+ let err = LoadError::Other(config::ConfigError::Message("bad".into()));
+ assert_eq!(err.to_string(), "bad");
+}
diff --git a/src/git/repository/mod.rs b/src/git/repository/mod.rs
index 947fcd3f1..5079ae966 100644
--- a/src/git/repository/mod.rs
+++ b/src/git/repository/mod.rs
@@ -78,7 +78,7 @@ use anyhow::{Context, bail};
use dunce::canonicalize;
-use crate::config::{ProjectConfig, ResolvedConfig, UserConfig};
+use crate::config::{LoadError, ProjectConfig, ResolvedConfig, UserConfig};
// Import types from parent module
use super::{DefaultBranchName, GitError, IntegrationReason, LineDiff, WorktreeInfo};
@@ -389,27 +389,53 @@ impl Repository {
/// would hide it from anyone not running with `RUST_LOG=warn`.
pub fn user_config(&self) -> &UserConfig {
self.cache.user_config.get_or_init(|| {
- UserConfig::load()
- .inspect_err(|err| {
- // Include the config file path so users know where to look.
- // Serde's flatten/Option wrapping loses the offending field
- // name inside the config crate's error, so the file path is
- // the most reliable pointer we can give.
- let path_hint = crate::config::config_path()
- .map(|p| format!(" at {}", crate::path::format_path_for_display(&p)))
- .unwrap_or_default();
- crate::styling::eprintln!(
- "{}",
- crate::styling::warning_message(format!(
- "Failed to load user config{path_hint}, using defaults: {err}"
- ))
- );
- crate::styling::eprintln!(
- "{}",
- crate::styling::hint_message(
- "If the value came from a WORKTRUNK_* env var, check those too.",
- )
- );
+ UserConfig::load_with_cause()
+ .inspect_err(|err| match err {
+ LoadError::File { path, label, err } => {
+ crate::styling::eprintln!(
+ "{}",
+ crate::styling::warning_message(format!(
+ "{label} at {} failed to parse, using defaults",
+ crate::path::format_path_for_display(path),
+ ))
+ );
+ crate::styling::eprintln!(
+ "{}",
+ crate::styling::format_with_gutter(&err.to_string(), None)
+ );
+ }
+ LoadError::Env {
+ err,
+ override_vars,
+ } => {
+ crate::styling::eprintln!(
+ "{}",
+ crate::styling::warning_message(format!(
+ "Failed to apply WORKTRUNK_* env var override, using defaults: {err}"
+ ))
+ );
+ // TODO: With source-tracking in the config layer
+ // (see collect_worktrunk_override_vars TODO) we could
+ // pinpoint the exact var and show its value, rather
+ // than dumping all override vars.
+ if !override_vars.is_empty() {
+ crate::styling::eprintln!(
+ "{}",
+ crate::styling::hint_message(format!(
+ "Currently set: {}",
+ override_vars.join(", ")
+ ))
+ );
+ }
+ }
+ LoadError::Other(err) => {
+ crate::styling::eprintln!(
+ "{}",
+ crate::styling::warning_message(format!(
+ "Failed to load user config, using defaults: {err}"
+ ))
+ );
+ }
})
.unwrap_or_default()
})
diff --git a/tests/integration_tests/list_config.rs b/tests/integration_tests/list_config.rs
index 23fd6c174..2efca8a20 100644
--- a/tests/integration_tests/list_config.rs
+++ b/tests/integration_tests/list_config.rs
@@ -417,6 +417,103 @@ branches = "not-a-bool"
});
}
+/// When a WORKTRUNK_* env var override fails (e.g. a string value for a typed
+/// field), the warning must blame env vars — not the config file — and list
+/// the override vars currently set.
+#[rstest]
+fn test_list_config_env_override_bad_value_warns_on_stderr(repo: TestRepo) {
+ let settings = setup_snapshot_settings(&repo);
+ settings.bind(|| {
+ let mut cmd = wt_command();
+ repo.configure_wt_cmd(&mut cmd);
+ // `list.branches` is Option<bool>; "not-a-bool" can't coerce.
+ cmd.env("WORKTRUNK__LIST__BRANCHES", "not-a-bool");
+ cmd.arg("list").current_dir(repo.root_path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+}
+
+/// Bad values in non-section fields (projects, skip-*-prompt) must still be
+/// attributed to the file, not to env vars. These fields are NOT caught by
+/// the OverridableConfig pre-validation (which only covers section fields) —
+/// the UserConfig fallback validation catches them.
+#[rstest]
+fn test_list_config_malformed_non_section_field_warns_on_stderr(repo: TestRepo) {
+ fs::write(
+ repo.test_config_path(),
+ "skip-shell-integration-prompt = \"not-a-bool\"\n",
+ )
+ .unwrap();
+
+ let mut settings = setup_snapshot_settings(&repo);
+ settings.add_filter(r"_PARENT_/[^\s,]*test-config\.toml", "[TEST_CONFIG]");
+ settings.bind(|| {
+ let mut cmd = wt_command();
+ repo.configure_wt_cmd(&mut cmd);
+ cmd.arg("list").current_dir(repo.root_path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+}
+
+/// Validation errors (e.g. empty worktree-path) are neither file parse
+/// errors nor env-var errors — they fire after successful deserialization.
+#[rstest]
+fn test_list_config_validation_error_warns_on_stderr(repo: TestRepo) {
+ fs::write(repo.test_config_path(), "worktree-path = \"\"\n").unwrap();
+
+ let settings = setup_snapshot_settings(&repo);
+ settings.bind(|| {
+ let mut cmd = wt_command();
+ repo.configure_wt_cmd(&mut cmd);
+ cmd.arg("list").current_dir(repo.root_path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+}
+
+/// System config with a section-field error (caught by OverridableConfig).
+#[rstest]
+fn test_list_config_malformed_system_config_warns_on_stderr(repo: TestRepo) {
+ let system_config = repo.root_path().join("system-config.toml");
+ fs::write(&system_config, "[list]\nbranches = \"not-a-bool\"\n").unwrap();
+
+ let mut settings = setup_snapshot_settings(&repo);
+ settings.add_filter(r"_REPO_/system-config\.toml", "[TEST_SYSTEM_CONFIG_FILE]");
+ settings.bind(|| {
+ let mut cmd = wt_command();
+ repo.configure_wt_cmd(&mut cmd);
+ cmd.env("WORKTRUNK_SYSTEM_CONFIG_PATH", &system_config);
+ cmd.arg("list").current_dir(repo.root_path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+}
+
+/// System config with a non-section field error (skips OverridableConfig,
+/// caught by the UserConfig fallback validation).
+#[rstest]
+fn test_list_config_malformed_system_config_non_section_field(repo: TestRepo) {
+ let system_config = repo.root_path().join("system-config.toml");
+ fs::write(
+ &system_config,
+ "skip-shell-integration-prompt = \"not-a-bool\"\n",
+ )
+ .unwrap();
+
+ let mut settings = setup_snapshot_settings(&repo);
+ settings.add_filter(r"_REPO_/system-config\.toml", "[TEST_SYSTEM_CONFIG_FILE]");
+ settings.bind(|| {
+ let mut cmd = wt_command();
+ repo.configure_wt_cmd(&mut cmd);
+ cmd.env("WORKTRUNK_SYSTEM_CONFIG_PATH", &system_config);
+ cmd.arg("list").current_dir(repo.root_path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+}
+
/// Test that --full disables the task timeout.
#[rstest]
fn test_list_config_timeout_disabled_with_full(repo: TestRepo) {
diff --git a/tests/snapshots/integration__integration_tests__list_config__list_config_env_override_bad_value_warns_on_stderr.snap b/tests/snapshots/integration__integration_tests__list_config__list_config_env_override_bad_value_warns_on_stderr.snap
new file mode 100644
index 000000000..6c25b7b81
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__list_config__list_config_env_override_bad_value_warns_on_stderr.snap
@@ -0,0 +1,55 @@
+---
+source: tests/integration_tests/list_config.rs
+info:
+ program: wt
+ args:
+ - list
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ WORKTRUNK__LIST__BRANCHES: not-a-bool
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+ Branch Status HEAD± main↕ Remote⇅ Path Commit Age Message
+@ main ^| | . 05a4a45d 16h Initial commit
++ feature-a ↑ ↑1 ../repo.feature-a 1b87d473 16h Add feature-a file
++ feature-b ↑ ↑1 ../repo.feature-b f62940fc 16h Add feature-b file
++ feature-c ↑ ↑1 ../repo.feature-c 345c7c93 16h Add feature-c file
+
+○ Showing 4 worktrees, 3 ahead
+
+----- stderr -----
+▲ Failed to apply WORKTRUNK_* env var override, using defaults: invalid type: string "not-a-bool", expected a boolean
+↳ Currently set: WORKTRUNK__LIST__BRANCHES
diff --git a/tests/snapshots/integration__integration_tests__list_config__list_config_malformed_config_warns_on_stderr.snap b/tests/snapshots/integration__integration_tests__list_config__list_config_malformed_config_warns_on_stderr.snap
index 2906c9dfe..cceebdacc 100644
--- a/tests/snapshots/integration__integration_tests__list_config__list_config_malformed_config_warns_on_stderr.snap
+++ b/tests/snapshots/integration__integration_tests__list_config__list_config_malformed_config_warns_on_stderr.snap
@@ -50,5 +50,9 @@ exit_code: 0
○ Showing 4 worktrees, 3 ahead
----- stderr -----
-▲ Failed to load user config at [TEST_CONFIG], using defaults: invalid type: string "not-a-bool", expected a boolean
-↳ If the value came from a WORKTRUNK_* env var, check those too.
+▲ User config at [TEST_CONFIG] failed to parse, using defaults
+  TOML parse error at line 2, column 12
+  |
+  2 | branches = "not-a-bool"
+  | ^^^^^^^^^^^^
+  invalid type: string "not-a-bool", expected a boolean
diff --git a/tests/snapshots/integration__integration_tests__list_config__list_config_malformed_non_section_field_warns_on_stderr.snap b/tests/snapshots/integration__integration_tests__list_config__list_config_malformed_non_section_field_warns_on_stderr.snap
new file mode 100644
index 000000000..1d1fd785a
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__list_config__list_config_malformed_non_section_field_warns_on_stderr.snap
@@ -0,0 +1,58 @@
+---
+source: tests/integration_tests/list_config.rs
+info:
+ program: wt
+ args:
+ - list
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+ Branch Status HEAD± main↕ Remote⇅ Path Commit Age Message
+@ main ^| | . 05a4a45d 16h Initial commit
++ feature-a ↑ ↑1 ../repo.feature-a 1b87d473 16h Add feature-a file
++ feature-b ↑ ↑1 ../repo.feature-b f62940fc 16h Add feature-b file
++ feature-c ↑ ↑1 ../repo.feature-c 345c7c93 16h Add feature-c file
+
+○ Showing 4 worktrees, 3 ahead
+
+----- stderr -----
+▲ User config at [TEST_CONFIG] failed to parse, using defaults
+  TOML parse error at line 1, column 33
+  |
+  1 | skip-shell-integration-prompt = "not-a-bool"
+  | ^^^^^^^^^^^^
+  invalid type: string "not-a-bool", expected a boolean
diff --git a/tests/snapshots/integration__integration_tests__list_config__list_config_malformed_system_config_non_section_field.snap b/tests/snapshots/integration__integration_tests__list_config__list_config_malformed_system_config_non_section_field.snap
new file mode 100644
index 000000000..ea862c711
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__list_config__list_config_malformed_system_config_non_section_field.snap
@@ -0,0 +1,58 @@
+---
+source: tests/integration_tests/list_config.rs
+info:
+ program: wt
+ args:
+ - list
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+ Branch Status HEAD± main↕ Remote⇅ Path Commit Age Message
+@ main ? ^| | . 05a4a45d 16h Initial commit
++ feature-a ↑ ↑1 ../repo.feature-a 1b87d473 16h Add feature-a file
++ feature-b ↑ ↑1 ../repo.feature-b f62940fc 16h Add feature-b file
++ feature-c ↑ ↑1 ../repo.feature-c 345c7c93 16h Add feature-c file
+
+○ Showing 4 worktrees, 1 with changes, 3 ahead
+
+----- stderr -----
+▲ System config at [TEST_SYSTEM_CONFIG_FILE] failed to parse, using defaults
+  TOML parse error at line 1, column 33
+  |
+  1 | skip-shell-integration-prompt = "not-a-bool"
+  | ^^^^^^^^^^^^
+  invalid type: string "not-a-bool", expected a boolean
diff --git a/tests/snapshots/integration__integration_tests__list_config__list_config_malformed_system_config_warns_on_stderr.snap b/tests/snapshots/integration__integration_tests__list_config__list_config_malformed_system_config_warns_on_stderr.snap
new file mode 100644
index 000000000..a21b3bc18
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__list_config__list_config_malformed_system_config_warns_on_stderr.snap
@@ -0,0 +1,58 @@
+---
+source: tests/integration_tests/list_config.rs
+info:
+ program: wt
+ args:
+ - list
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+ Branch Status HEAD± main↕ Remote⇅ Path Commit Age Message
+@ main ? ^| | . 05a4a45d 16h Initial commit
++ feature-a ↑ ↑1 ../repo.feature-a 1b87d473 16h Add feature-a file
++ feature-b ↑ ↑1 ../repo.feature-b f62940fc 16h Add feature-b file
++ feature-c ↑ ↑1 ../repo.feature-c 345c7c93 16h Add feature-c file
+
+○ Showing 4 worktrees, 1 with changes, 3 ahead
+
+----- stderr -----
+▲ System config at [TEST_SYSTEM_CONFIG_FILE] failed to parse, using defaults
+  TOML parse error at line 2, column 12
+  |
+  2 | branches = "not-a-bool"
+  | ^^^^^^^^^^^^
+  invalid type: string "not-a-bool", expected a boolean
diff --git a/tests/snapshots/integration__integration_tests__list_config__list_config_validation_error_warns_on_stderr.snap b/tests/snapshots/integration__integration_tests__list_config__list_config_validation_error_warns_on_stderr.snap
new file mode 100644
index 000000000..7479ed024
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__list_config__list_config_validation_error_warns_on_stderr.snap
@@ -0,0 +1,53 @@
+---
+source: tests/integration_tests/list_config.rs
+info:
+ program: wt
+ args:
+ - list
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+ Branch Status HEAD± main↕ Remote⇅ Path Commit Age Message
+@ main ^| | . 05a4a45d 16h Initial commit
++ feature-a ↑ ↑1 ../repo.feature-a 1b87d473 16h Add feature-a file
++ feature-b ↑ ↑1 ../repo.feature-b f62940fc 16h Add feature-b file
++ feature-c ↑ ↑1 ../repo.feature-c 345c7c93 16h Add feature-c file
+
+○ Showing 4 worktrees, 3 ahead
+
+----- stderr -----
+▲ Failed to load user config, using defaults: worktree-path cannot be empty
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__invalid_toml.snap b/tests/snapshots/integration__integration_tests__post_start_commands__invalid_toml.snap
index 73b1c73c0..514c2955e 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__invalid_toml.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__invalid_toml.snap
@@ -46,7 +46,8 @@ exit_code: 1
----- stderr -----
✗ Failed to load project config
-  Failed to parse TOML: TOML parse error at line 1, column 30
+  Project config at _REPO_/.config/wt.toml failed to parse:
+  TOML parse error at line 1, column 30
  |
  1 | post-create = [invalid syntax
  | ^