{"record":{"id":"4bd4880fd68a46e6","repo":"the-benchmarker/web-frameworks","slug":"failed-to-build-compose-settings-for-profile-profile-str-err","errorCode":null,"errorMessage":"Failed to build/compose settings for profile `{profile_str}`: {err}","messagePattern":"Failed to build/compose settings for profile `(.+?)`: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/reinhardt-web/src/config/settings.rs","lineNumber":98,"sourceCode":"    // Build settings by merging sources in priority order.\n    // `build_composed::<T>()` uses `MergeStrategy::Deep` by default, so a\n    // single key in `production.toml` overrides only that key — sibling\n    // entries inside the same nested table inherit from `base.toml`.\n    SettingsBuilder::new()\n        .profile(profile)\n        // Lowest priority: Default values\n        .add_source(DefaultSource::new())\n        // Medium priority: Base TOML file\n        .add_source(TomlFileSource::new(settings_dir.join(\"base.toml\")))\n        // Profile priority: Environment-specific TOML file\n        .add_source(TomlFileSource::new(\n            settings_dir.join(format!(\"{}.toml\", profile_str)),\n        ))\n        // Highest priority: explicit process environment overrides\n        .add_source(HighPriorityEnvSource::new().with_prefix(\"REINHARDT_\"))\n        .build_composed::<ProjectSettings>()\n        .unwrap_or_else(|err| {\n            panic!(\"Failed to build/compose settings for profile `{profile_str}`: {err}\")\n        })\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    fn test_get_settings() {\n        // Smoke test: ensures settings load without panic and required fields are present\n        let settings = get_settings();\n        assert!(\n            !settings.core.secret_key.is_empty(),\n            \"secret_key should be populated from settings sources\"\n        );\n    }\n}\n","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/the-benchmarker/web-frameworks/blob/3795a31d724e41cdb87b6e0d3ac941b7bfac3ea2/rust/reinhardt-web/src/config/settings.rs#L80-L116","documentation":"reinhardt-web's get_settings() composes ProjectSettings from base.toml, the profile-specific <profile>.toml, and REINHARDT_-prefixed environment overrides via build_composed::<ProjectSettings>(). If any source fails to load/parse or the merged values do not satisfy ProjectSettings, the unwrap_or_else panics naming the profile and the underlying error.","triggerScenarios":"Calling get_settings() when settings/base.toml or settings/<REINHARDT_ENV>.toml is missing, unreadable, contains invalid TOML, or fails type/required-field validation during build_composed::<ProjectSettings>() — e.g. REINHARDT_ENV is set to a profile with no corresponding toml file.","commonSituations":"REINHARDT_ENV set to production/staging but settings/production.toml was never committed; a typo in a toml key that deserialization rejects; wrong value type in a config file; deploy environment lacks the settings directory because packaging excluded it.","solutions":["Check the embedded err in the panic message: ensure settings/<profile>.toml exists for the current REINHARDT_ENV value (default profile is 'local')","Fix TOML syntax/type errors in base.toml or the profile file according to the deserialization error","Set REINHARDT_ENV to a profile that has a corresponding toml file, or create that file","Replace the panic in get_settings with a Result-returning API so misconfiguration surfaces as a startup error with context instead of a panic","Verify REINHARDT_-prefixed environment variable values parse into the expected field types"],"exampleFix":"// before\nREINHARDT_ENV=production cargo run\n// -> panic: Failed to build/compose settings for profile `production`: ... No such file\n\n// after\nls settings/  # base.toml local.toml\ncp settings/local.toml settings/production.toml  # then edit per-env values\nexport REINHARDT_ENV=production","handlingStrategy":"validation","validationCode":"// before starting the app, verify the profile file and required keys exist\nlet profile = std::env::var(\"REINHARDT_ENV\").unwrap_or_else(|_| \"local\".into());\nlet path = format!(\"settings/{profile}.toml\");\nif !std::path::Path::new(\"settings/base.toml\").exists()\n    || !std::path::Path::new(&path).exists()\n{\n    eprintln!(\"missing settings file for profile '{profile}' (expected {path})\");\n    std::process::exit(1);\n}\n// optionally parse-check the TOML first:\n// toml::from_str::<toml::Value>(&std::fs::read_to_string(&path)?)?;","typeGuard":"null","tryCatchPattern":"// get_settings panics on config failure; isolate it at startup\nlet settings = std::panic::catch_unwind(|| reinhardt_web::config::settings::get_settings())\n    .unwrap_or_else(|_| {\n        eprintln!(\"failed to compose settings; check settings/*.toml and REINHARDT_ENV\");\n        std::process::exit(1);\n    });","preventionTips":["Commit base.toml and every profile-specific toml referenced by REINHARDT_ENV","Validate settings files in CI (toml parse + deserialize into ProjectSettings) before deploy","Keep REINHARDT_ environment variable names/types aligned with ProjectSettings fields","Fail deployments fast with a config smoke test in the entrypoint script"],"tags":["rust","config","toml","panic"],"backgroundTag":"config-file-not-found","analyzedSha":"3795a31d724e41cdb87b6e0d3ac941b7bfac3ea2","analyzedAt":"2026-09-15T02:39:22.409Z","contentChangedAt":"2026-09-15T02:39:22.409Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}