{"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":986,"sourceCode":"        }\n        // Environment-only: the CLI layer plus `MISE_*`. It skips config discovery, which is both\n        // what makes it survive the failure that sent us here and why its answer is a fallback\n        // rather than the real one.\n        let mut settings =\n            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        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()).env();\n        if policy.source == SettingsSourcePolicy::Hierarchy {\n            for layer in Self::settings_layers_from(root, policy.trust) {\n                builder = builder.preloaded(layer);\n            }\n            builder = builder.preloaded(DEFAULT_SETTINGS.clone());\n        }\n        let mut settings = builder.load()?;\n        normalize_storage_dirs(&mut settings)?;\n        validate_settings_enum_values(&settings)?;\n        Ok(settings)\n    }\n\n    /// Load eligible config-file settings layers in precedence order and combine settings whose\n    /// semantics are additive across files.\n    fn settings_layers_from(\n        root: Option<&Path>,","sourceCodeStart":968,"sourceCodeEnd":1004,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/config/settings.rs#L968-L1004","documentation":"This error is thrown by Settings::load_sources_from when the requested load policy demands trusted-only settings resolution (SettingsTrustPolicy::TrustedOnly) but the global base settings have not yet been loaded into process state (is_loaded() is false). Trusted project-file resolution depends on the trust list and state established by the initial base settings load, so calling it first is an ordering violation.","triggerScenarios":"Calling load_sources_from with a policy whose trust is TrustedOnly (root-specific/trusted project settings resolution) before any normal Settings load has run in the process — e.g. invoking trusted config resolution very early in startup, or in a test/helper, ahead of the base `Settings::try_get`/get flow.","commonSituations":"Developers adding root-specific trusted-config features call the trusted resolver from a code path that runs before mise's normal settings initialization; tests that call trusted settings helpers without first loading base settings.","solutions":["Ensure the base settings are loaded first (call the normal Settings load/try_get path) before requesting trusted-only resolution","Switch the call site to the non-TrustedOnly policy if trust filtering is not actually required","In tests, initialize settings (e.g. via Settings::try_get or the standard load) before invoking trusted resolution","If this occurs in normal CLI startup, report it: it indicates settings-init ordering was broken upstream"],"exampleFix":"// before\nlet s = Settings::load_sources_from(root, policy_trusted_only)?;\n\n// after\nlet _ = Settings::try_get()?; // ensure base settings loaded first\nlet s = Settings::load_sources_from(root, policy_trusted_only)?;","handlingStrategy":"type-guard","validationCode":"// rust: guard before trusted-only resolution\nif policy.trust == SettingsTrustPolicy::TrustedOnly && !mise::config::settings::is_loaded() {\n    // load base settings first or take the non-trusted path\n}","typeGuard":"// rust\nfn can_resolve_trusted(policy: SettingsLoadPolicy) -> bool {\n    policy.trust != SettingsTrustPolicy::TrustedOnly || mise::config::settings::is_loaded()\n}","tryCatchPattern":null,"preventionTips":["Treat the base settings load as a required init step in any code path that resolves trusted project settings","In tests, call the standard settings initializer in setup before trusted helpers","Prefer the normal Settings::try_get flow unless trusted-only semantics are explicitly required","Document the ordering requirement at the call site"],"tags":["settings","internal","mise"],"backgroundTag":"invalid-state-transition","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}