{"record":{"id":"6fe6f35bf57793f2","repo":"jdx/mise","slug":"task-cache-command-input-must-not-be-empty-co-6fe6f3","errorCode":null,"errorMessage":"task {} cache command input must not be empty: {command:?}","messagePattern":"task (.+?) cache command input must not be empty: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/task/task_executor.rs","lineNumber":1426,"sourceCode":"            sandbox.filter_env(resolved_env)\n        } else {\n            resolved_env.clone()\n        };\n        let timeout = task\n            .timeout\n            .as_ref()\n            .and_then(|value| match duration::parse_duration(value) {\n                Ok(timeout) => Some(timeout),\n                Err(err) => {\n                    warn!(\"invalid timeout {:?} for task {}: {err}\", value, task.name);\n                    None\n                }\n            })\n            .unwrap_or(COMMAND_INPUT_TIMEOUT);\n        let mut inputs = Vec::with_capacity(cache.command_inputs.len());\n        for command in &cache.command_inputs {\n            if command.trim().is_empty() {\n                eyre::bail!(\n                    \"task {} cache command input must not be empty: {command:?}\",\n                    task.name\n                );\n            }\n            let (program, args, cmd_verbatim) =\n                self.get_cmd_program_and_args(command, task, &[])?;\n            // The same refusal as in `exec_program`, and it matters more here: these commands feed\n            // the cache key, so running them from C:\\Windows would hash the wrong directory's\n            // answer. Measured on 2026.8.6 with the project on a UNC share — a `command_inputs`\n            // entry reading a file that exists in the project fails, while the same config on a\n            // local path succeeds. `--dry-run` does not reach here (see the cache branch in\n            // `run_task`), so there is nothing to exempt.\n            #[cfg(windows)]\n            if cmd_shell_cannot_use_dir(&program, &root) {\n                eyre::bail!(\"{}\", unc_working_dir_error(&root));\n            }\n            #[cfg(not(windows))]\n            let _ = cmd_verbatim;","sourceCodeStart":1408,"sourceCodeEnd":1444,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/task/task_executor.rs#L1408-L1444","documentation":"Before replaying a cached task, mise validates each recorded command input; a command whose trimmed content is empty (empty string or whitespace only) cannot be executed or hashed meaningfully, so the executor bails naming the task and the offending command. This indicates corrupted or improperly recorded cache metadata.","triggerScenarios":"Replaying a task cache whose command_inputs list contains an empty or whitespace-only string — e.g. cache metadata written by a producer that recorded blank commands, or hand-edited/corrupted cache files.","commonSituations":"Task definitions whose command resolved to an empty string due to templating failures or misconfigured env; corrupted local cache files; manually edited or programmatically generated cache metadata with blank entries.","solutions":["Clear the task's cached entry (e.g. `mise cache` cleanup or removing the task cache dir) and re-run the task to rebuild valid metadata.","Fix the task definition so the command string is non-empty — check template expressions and env-driven command construction.","Find and fix the producer that wrote an empty command_inputs entry into the cache.","Guard templated commands with a fallback/default so they can never evaluate to an empty string."],"exampleFix":"// before (mise.toml): template collapses to empty\nrun = \"{{env.OPTIONAL_CMD}}\"\n// after: provide a non-empty fallback\nrun = \"{{env.OPTIONAL_CMD ?? echo skipping}}\"","handlingStrategy":"validation","validationCode":"const cmds = cache.commandInputs ?? [];\nif (cmds.some(c => !c || !c.trim())) throw new Error('cache metadata contains an empty command input');","typeGuard":"const nonEmptyCmd = (c) => typeof c === 'string' && c.trim().length > 0;","tryCatchPattern":"try {\n  await runCached(task);\n} catch (e) {\n  if (String(e).includes('cache command input must not be empty')) {\n    clearTaskCache(task.name);\n    await runCached(task);\n  } else throw e;\n}","preventionTips":["Give templated commands non-empty defaults so they never resolve to ''.","Clear stale cache entries after editing task definitions.","Reject blank command strings when writing cache metadata."],"tags":["task-cache","task-executor","empty-input","validation"],"backgroundTag":"empty-required-field","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"}