{"record":{"id":"9b51a4d0343cbf55","repo":"jdx/mise","slug":"agent-name-nice-must-be-between-20-and-20","errorCode":null,"errorMessage":"agent '{name}' `nice` must be between -20 and 20","messagePattern":"agent '(.+?)' `nice` must be between -20 and 20","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/launchd.rs","lineNumber":124,"sourceCode":"    pub state: LaunchdState,\n}\n\nimpl LaunchdRequest {\n    pub(crate) fn from_toml(name: String, config: LaunchdTomlConfig) -> Result<Self> {\n        if !valid_name(&name) {\n            bail!(\"agent name '{name}' must contain only letters, numbers, '.', '_', or '-'\");\n        }\n        let Some(program) = config.program.map(|s| s.trim().to_string()) else {\n            bail!(\"agent '{name}' must set `program`\");\n        };\n        if program.is_empty() {\n            bail!(\"agent '{name}' must set a non-empty `program`\");\n        }\n        if config.keep_alive && config.keep_alive_on_failure {\n            bail!(\"agent '{name}' cannot set both `keep_alive` and `keep_alive_on_failure`\");\n        }\n        if config.nice.is_some_and(|nice| !(-20..=20).contains(&nice)) {\n            bail!(\"agent '{name}' `nice` must be between -20 and 20\");\n        }\n        if let Some(interval) = &config.start_calendar_interval {\n            interval.validate(&name)?;\n        }\n        for dir in &config.queue_directories {\n            if dir.trim().is_empty() {\n                bail!(\"agent '{name}' `queue_directories` must not contain empty entries\");\n            }\n            // checked against the raw string rather than `Path::is_absolute` on the\n            // expanded value: the plist is consumed by macOS launchd, so POSIX rules\n            // apply regardless of the platform parsing the config, and on Windows\n            // `Path::new(\"/var/spool\").is_absolute()` is false (root, but no prefix)\n            if !is_absolute_launchd_path(dir) {\n                bail!(\n                    \"agent '{name}' `queue_directories` entry '{dir}' must be an absolute path \\\n                     (launchd requires absolute paths; `~` and `~/` are expanded)\"\n                );\n            }","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/launchd.rs#L106-L142","documentation":"launchd's `nice` value (process priority) must be between -20 (highest priority) and 20 (lowest). LaunchdRequest::from_toml validates any configured nice value against this inclusive range and bails otherwise. This prevents generating a plist launchd would reject or misinterpret.","triggerScenarios":"Setting nice = -30, nice = 25, or any value outside [-20, 20] in an agent config (config.nice is Some and out of range).","commonSituations":"Copying Unix renice conventions where -20..19 differ slightly; typos like -200; intending 'very high priority' with values below -20.","solutions":["Change nice to a value within -20..=20","Use nice = 0 for default priority","Omit `nice` entirely if priority tuning is not needed"],"exampleFix":"# before\n[agent.indexer]\nprogram = \"/usr/bin/indexer\"\nnice = -30\n# after\n[agent.indexer]\nprogram = \"/usr/bin/indexer\"\nnice = 10","handlingStrategy":"validation","validationCode":"nice = agent_cfg.get(\"nice\")\nif nice is not None and not (-20 <= nice <= 20):\n    raise ValueError(f\"nice {nice} out of range\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember launchd nice range is -20..20","Clamp computed nice values before writing them to config","Prefer positive (lower-priority) nice values unless you have root"],"tags":["launchd","config","range"],"backgroundTag":"value-out-of-range","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"}