{"record":{"id":"31f675e30807d098","repo":"jdx/mise","slug":"scheduled-task-name-name-contains-characters-t","errorCode":null,"errorMessage":"scheduled task name {name:?} contains characters that cannot be queried","messagePattern":"scheduled task name (.+?) contains characters that cannot be queried","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/scheduled_tasks.rs","lineNumber":473,"sourceCode":"/// The task's state through the Task Scheduler API rather than the\n/// localized text `schtasks /query` prints. Prints `MISSING` for an\n/// unregistered task and the `TaskState` name otherwise. The name is\n/// embedded in the script (arguments after `-Command` are more command\n/// text, not `$args`); names are validated to letters, digits, `.`, `_`,\n/// and `-` before they get here.\nfn query_script(name: &str) -> String {\n    format!(\n        \"$t = Get-ScheduledTask -TaskPath '\\\\mise\\\\' -TaskName '{name}' -ErrorAction SilentlyContinue; if ($null -eq $t) {{ 'MISSING' }} else {{ $t.State.ToString() }}\"\n    )\n}\n\nasync fn query(task: &str) -> Result<Option<Query>> {\n    let name = task.strip_prefix(\"mise\\\\\").unwrap_or(task);\n    if !name\n        .chars()\n        .all(|c| c.is_ascii_alphanumeric() || matches!(c, '.' | '_' | '-'))\n    {\n        bail!(\"scheduled task name {name:?} contains characters that cannot be queried\");\n    }\n    let args = [\n        \"-NoProfile\".to_string(),\n        \"-NonInteractive\".to_string(),\n        \"-Command\".to_string(),\n        query_script(name),\n    ];\n    debug!(\"$ powershell {}\", shell_words::join(&args));\n    let mut cmd = tokio::process::Command::new(\"powershell.exe\");\n    cmd.args(&args)\n        .stdin(Stdio::null())\n        .stdout(Stdio::piped())\n        .stderr(Stdio::piped())\n        .kill_on_drop(true);\n    let output = tokio::time::timeout(SCHTASKS_TIMEOUT, cmd.output())\n        .await\n        .map_err(|_| eyre!(\"querying scheduled task {task} timed out\"))??;\n    if !output.status.success() {","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/scheduled_tasks.rs#L455-L491","documentation":"On Windows, mise queries scheduled tasks by shelling out to schtasks via a PowerShell wrapper. Because the task name is interpolated into a PowerShell command, names containing characters outside [A-Za-z0-9._-] are rejected up front to prevent injection and malformed queries. This is a deliberate safety/validation bail, not a lookup miss.","triggerScenarios":"Calling mise scheduled-task status/exists/apply (via src/system/scheduled_tasks.rs::query) with a task name that has a path separator, space, backslash prefix beyond the stripped 'mise\\\\', unicode characters, or shell metacharacters.","commonSituations":"A mise.toml [scheduled_task] name was written with a space or slash (e.g. \"my task\", \"backup/daily\"), or a task name derived from a path or env var picks up unexpected characters; also backslash-heavy Windows naming habits colliding with the strict whitelist.","solutions":["Rename the scheduled task in mise.toml (or wherever it is declared) to use only ASCII letters, digits, '.', '_' and '-'","If the name comes from a variable or template, sanitize/normalize it to the allowed character set before it reaches the config","If you believe the character is safe, file an issue to extend the whitelist; do not work around it by crafting names with escapes"],"exampleFix":"// before\n[scheduled_task.backup-job.daily]\ncron = \"0 3 * * *\"\n// after\n[scheduled_task.backup_job_daily]\ncron = \"0 3 * * *\"","handlingStrategy":"validation","validationCode":"fn valid_task_name(name: &str) -> bool {\n    let name = name.strip_prefix(\"mise\\\\\").unwrap_or(name);\n    !name.is_empty()\n        && name.chars().all(|c| c.is_ascii_alphanumeric() || matches!(c, '.' | '_' | '-'))\n}\n// assert!(valid_task_name(\"backup_daily\"));","typeGuard":"fn is_safe_task_name(s: &str) -> bool {\n    s.chars().all(|c| c.is_ascii_alphanumeric() || matches!(c, '.' | '_' | '-'))\n}","tryCatchPattern":null,"preventionTips":["Use only [A-Za-z0-9._-] when naming scheduled tasks in mise.toml","Never embed spaces, slashes, or backslashes in task names on Windows","Validate names generated from templates or env vars before writing config"],"tags":["windows","validation","scheduled-tasks","naming"],"backgroundTag":"invalid-identifier-format","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"}