{"record":{"id":"5224fcb9ed11ce3c","repo":"atuinsh/atuin","slug":"could-not-build-default","errorCode":null,"errorMessage":"Could not build default","messagePattern":"Could not build default","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/atuin-client/src/settings.rs","lineNumber":1863,"sourceCode":"            .add_source(ConfigFile::from_str(toml, FileFormat::Toml))\n            .build()?;\n\n        let settings: Self = config.try_deserialize()?;\n        if let Some(dir) = &settings.data_dir {\n            shellexpand::full(dir).map_err(ValidationError::DataDir)?;\n        }\n\n        settings.ui.validate()?;\n        Ok(())\n    }\n}\n\nimpl Default for Settings {\n    fn default() -> Self {\n        // if this panics something is very wrong, as the default config\n        // does not build or deserialize into the settings struct\n        Self::builder()\n            .expect(\"Could not build default\")\n            .build()\n            .expect(\"Could not build config\")\n            .try_deserialize()\n            .expect(\"Could not deserialize config\")\n    }\n}\n\n/// Error returned by [`Settings::validate_str`] when validation fails.\n#[derive(Debug, Error)]\npub enum ValidationError {\n    #[error(transparent)]\n    Config(#[from] config::ConfigError),\n\n    #[error(transparent)]\n    Ui(#[from] UiValidationError),\n\n    #[error(\"failed to expand `data_dir`: {0}\")]\n    DataDir(shellexpand::LookupError<std::env::VarError>),","sourceCodeStart":1845,"sourceCodeEnd":1881,"githubUrl":"https://github.com/atuinsh/atuin/blob/900007c48045867e7f44b0f9bc55ad9dbe99ee0d/crates/atuin-client/src/settings.rs#L1845-L1881","documentation":"`impl Default for Settings` builds the configuration purely from programmatic defaults (no user config file) and `.expect(\"Could not build default\")` panics if `Settings::builder()` itself fails. The builder's job is to assemble default sources; failure means default values could not even be attached, which the code comments acknowledge means \"something is very wrong\".","triggerScenarios":"Calling `Settings::default()` (or anything that falls back to it) when `Settings::builder()` returns Err — e.g. the builder cannot add its default sources, or an environment-dependent step inside builder() (env prefix setup, source loading) errors.","commonSituations":"Only after code changes to `Settings::builder()` or the `config` crate: a renamed env var prefix, a broken config source path, or a dependency regression. Not reachable through user configuration.","solutions":["Diff `Settings::builder()` against its last working version; a recently added ConfigBuilder step likely errors.","Check the `config` crate version for behavioral changes in builder/source APIs; pin or adapt.","Run with RUST_BACKTRACE=1 to locate which builder step fails.","Report upstream — Default must always construct."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Panic-based; isolate if embedding:\nlet settings = std::panic::catch_unwind(Settings::default)\n    .map_err(|_| anyhow::anyhow!(\"Settings::builder() failed; internal invariant broken\"))?;","preventionTips":["Do not modify Settings::builder() without running the full test suite.","Track `config` crate changelog for source/builder API changes when upgrading.","Use RUST_BACKTRACE=1 to identify the failing builder step if it occurs."],"tags":["config","panic","internal-invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"900007c48045867e7f44b0f9bc55ad9dbe99ee0d","analyzedAt":"2026-09-19T12:52:51.491Z","contentChangedAt":"2026-09-19T12:52:51.491Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}