{"record":{"id":"fc26fe2ac69c52aa","repo":"jdx/mise","slug":"trusted-settings-resolution-requires-the-base-sett","errorCode":null,"errorMessage":"trusted settings resolution requires the base settings to be loaded","messagePattern":"trusted settings resolution requires the base settings to be loaded","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/config/settings.rs","lineNumber":1003,"sourceCode":"            Self::load_sources_from(None, SettingsLoadPolicy::ENVIRONMENT_ONLY).ok()?;\n        normalize_verbosity(&mut settings);\n        Some(settings.log_level())\n    }\n\n    /// Load settings sources for an explicit root, or the current directory when `root` is `None`.\n    ///\n    /// This shares source ordering and file parsing with the normal settings load. It deliberately\n    /// does not update process-global settings state or apply the post-load process side effects in\n    /// [`Self::try_get`]. Root-specific callers can require trusted project files without\n    /// reproducing config discovery or precedence rules.\n    fn load_sources_from(root: Option<&Path>, policy: SettingsLoadPolicy) -> Result<Self> {\n        let policy = if PACKAGE_QUERY_SETTINGS.load(Ordering::Relaxed) {\n            SettingsLoadPolicy::ENVIRONMENT_ONLY\n        } else {\n            policy\n        };\n        if policy.trust == SettingsTrustPolicy::TrustedOnly && !is_loaded() {\n            bail!(\"trusted settings resolution requires the base settings to be loaded\");\n        }\n        let mut builder = Self::builder().preloaded(Self::cli_settings_layer());\n        if [\n            \"MISE_PYPI_UVX\",\n            \"MISE_PIPX_UVX\",\n            \"MISE_PYPI_REGISTRY_URL\",\n            \"MISE_PIPX_REGISTRY_URL\",\n        ]\n        .iter()\n        .any(|name| std::env::var_os(name).is_some())\n        {\n            let mut env_aliases = Self::builder().env().load()?;\n            env_aliases.normalize_pypi_aliases()?;\n            let mut alias_layer = SettingsPartial::default();\n            // Normalize the environment as its own source before layering it over files.\n            if std::env::var_os(\"MISE_PYPI_UVX\").is_some()\n                || std::env::var_os(\"MISE_PIPX_UVX\").is_some()\n            {","sourceCodeStart":985,"sourceCodeEnd":1021,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/config/settings.rs#L985-L1021","documentation":"When the trust policy is TrustedOnly, mise resolves settings using only config files that have been explicitly trusted. This check in `Settings::load_sources_from` refuses to resolve trusted settings before the base settings (which record which files are trusted) have been loaded, because trust decisions would otherwise be made from incomplete data. It is a guard against resolving settings too early in the bootstrap sequence.","triggerScenarios":"Calling settings resolution with a SettingsLoadPolicy whose trust is SettingsTrustPolicy::TrustedOnly while `Settings::is_loaded()` is still false — i.e. requesting trusted-only resolution before the initial base-settings load has completed.","commonSituations":"Internal ordering bugs in custom config loading paths or plugins that call settings resolution before mise finished its normal startup load; code that resolves trusted config during early CLI parsing before the trusted-files registry exists.","solutions":["Ensure the base settings are loaded first (call the normal settings load / config load entry point) before resolving with TrustedOnly policy.","If trusted-only resolution is not actually required, use a load policy without SettingsTrustPolicy::TrustedOnly.","If you hit this in the mise codebase, move the call site later in the bootstrap sequence so `is_loaded()` returns true."],"exampleFix":"// before\nlet settings = Settings::load_sources_from(root, Some(SettingsLoadPolicy::trusted_only()), None)?;\n// after\nconfig::load_ignoring_global_config()?; // ensures base settings loaded\nlet settings = Settings::load_sources_from(root, Some(SettingsLoadPolicy::trusted_only()), None)?;","handlingStrategy":"try-catch","validationCode":"// rust: only resolve with TrustedOnly after base settings loaded\nif policy.trust == SettingsTrustPolicy::TrustedOnly && !settings::is_loaded() {\n    return Err(anyhow!(\"resolve base settings before trusted-only resolution\"));\n}","typeGuard":null,"tryCatchPattern":"// call settings resolution inside a context that guarantees prior config::load\nlet settings = config::load()?.settings;","preventionTips":["Always bootstrap via the normal config::load entry point before custom settings resolution.","Avoid TrustedOnly policy unless you specifically need it.","Add an assertion in tests that is_loaded() is true before trusted resolution paths run."],"tags":["config","settings","trust","initialization-order"],"backgroundTag":"invalid-state-transition","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}