{"record":{"id":"447ffacd123cdc8b","repo":"jdx/mise","slug":"service-unit-name-has-invalid-nice-value-ni","errorCode":null,"errorMessage":"service unit '{name}' has invalid `nice` value {nice}; expected -20 through 19","messagePattern":"service unit '(.+?)' has invalid `nice` value (.+?); expected -20 through 19","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/systemd.rs","lineNumber":221,"sourceCode":"                    \"timer unit '{name}' cannot set service-only directive(s): {}\",\n                    service_only_fields.join(\", \")\n                );\n            }\n            if config.on_boot_sec.is_none()\n                && config.on_unit_active_sec.is_none()\n                && config.on_unit_inactive_sec.is_none()\n                && config.on_calendar.is_none()\n            {\n                bail!(\n                    \"timer unit '{name}' must set at least one of `on_boot_sec`, \\\n                     `on_unit_active_sec`, `on_unit_inactive_sec`, or `on_calendar`\"\n                );\n            }\n        }\n        if let Some(nice) = config.nice\n            && !(-20..=19).contains(&nice)\n        {\n            bail!(\"service unit '{name}' has invalid `nice` value {nice}; expected -20 through 19\");\n        }\n        if let Some(umask) = &config.umask\n            && !valid_umask(umask)\n        {\n            bail!(\n                \"service unit '{name}' has invalid `umask` value '{umask}'; expected an octal access mask from 0000 through 0777\"\n            );\n        }\n        let wanted_by = config.wanted_by.unwrap_or_else(|| match kind {\n            SystemdUnitKind::Service => vec![\"default.target\".to_string()],\n            SystemdUnitKind::Timer => vec![\"timers.target\".to_string()],\n        });\n        Ok(Self {\n            unit: format!(\n                \"dev.mise.{name}.{}\",\n                match kind {\n                    SystemdUnitKind::Service => \"service\",\n                    SystemdUnitKind::Timer => \"timer\",","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/systemd.rs#L203-L239","documentation":"The optional `nice` value for a service unit must be within the kernel's valid range of -20 (highest priority) through 19 (lowest). `from_toml` validates this before generating the unit file so systemd does not reject it later.","triggerScenarios":"Setting `nice` to any integer outside -20..=19 (e.g. `nice = 25` or `nice = -21`) in a `[systemd.<name>]` block that resolves to a Service.","commonSituations":"Off-by-one mistakes thinking the range is 0-19 (forgetting negatives are root-privileged); typos like `nice = -2O`; copying values from other tools with different ranges.","solutions":["Change `nice` to a value between -20 and 19 (e.g. `nice = 10`).","Note that negative nice values typically require root/CAP_SYS_NICE at runtime; prefer a non-negative value if the service runs unprivileged.","Remove the `nice` key entirely if priority tuning is not needed."],"exampleFix":"# before\n[systemd.myapp]\nexec_start = \"/usr/bin/myapp\"\nnice = 25\n\n# after\n[systemd.myapp]\nexec_start = \"/usr/bin/myapp\"\nnice = 10","handlingStrategy":"validation","validationCode":"fn valid_nice(n: i32) -> bool { (-20..=19).contains(&n) }\nassert!(valid_nice(10) && !valid_nice(25));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp nice values to -20..=19 when generating configs programmatically.","Prefer non-negative nice values for unprivileged services.","Don't copy nice ranges from other tools with different bounds."],"tags":["systemd","validation","range","nice"],"backgroundTag":"value-out-of-range","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"}