{"record":{"id":"07b1f6aa4e6ebeb8","repo":"jdx/mise","slug":"task-cache-requires-explicit-outputs-or-outputs","errorCode":null,"errorMessage":"task {} cache requires explicit outputs or outputs = []","messagePattern":"task (.+?) cache requires explicit outputs or outputs = \\[\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/task/task_cache.rs","lineNumber":1207,"sourceCode":"    text.escape_debug().to_string()\n}\n\n/// Returns the versioned directory containing task artifact cache entries.\npub(crate) fn task_cache_dir() -> PathBuf {\n    Settings::get()\n        .task\n        .cache_dir\n        .clone()\n        .unwrap_or_else(|| dirs::CACHE.join(\"task-artifacts\"))\n        .join(CACHE_DIR_VERSION)\n}\n\npub(crate) fn validate_config(task: &Task, root: &Path) -> Result<()> {\n    if task.sources.is_empty() {\n        bail!(\"task {} cache requires at least one source\", task.name);\n    }\n    if task.outputs.is_auto() {\n        bail!(\n            \"task {} cache requires explicit outputs or outputs = []\",\n            task.name\n        );\n    }\n    if let Some(command) = task.cache.as_ref().and_then(|cache| {\n        cache\n            .command_inputs\n            .iter()\n            .find(|command| command.trim().is_empty())\n    }) {\n        bail!(\n            \"task {} cache command input must not be empty: {command:?}\",\n            task.name\n        );\n    }\n    let patterns = task.outputs.patterns();\n    if !patterns.is_empty() && output_glob_patterns(&patterns).is_empty() {\n        bail!(","sourceCodeStart":1189,"sourceCodeEnd":1225,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/task/task_cache.rs#L1189-L1225","documentation":"A cacheable task must state its outputs explicitly: either a list of output patterns or an explicit empty list (outputs = []) meaning the task produces no artifacts worth caching. The special 'auto' outputs mode is rejected because cache correctness requires knowing exactly which paths to archive and restore.","triggerScenarios":"validate_config for a task where task.outputs.is_auto() is true — i.e. the task relies on default/auto output discovery while artifact caching is enabled, instead of declaring outputs in mise.toml.","commonSituations":"Copying a task definition that previously ran without caching and enabling cache on it; omitting the outputs key expecting mise to infer it; template-generated tasks that never set outputs.","solutions":["Declare explicit outputs in the task config, e.g. outputs = [\"dist\"] (glob patterns allowed).","If the task produces no files, set outputs = [] explicitly.","Check the named task's mise.toml block and remove reliance on auto outputs.","Use `mise tasks info <task>` to confirm the outputs configuration was picked up."],"exampleFix":"// before (mise.toml)\n[tasks.build]\nrun = \"vite build\"\nsources = [\"src/**/*\"]\n// after\n[tasks.build]\nrun = \"vite build\"\nsources = [\"src/**/*\"]\noutputs = [\"dist\"]   # or outputs = [] if there are none","handlingStrategy":"validation","validationCode":"const outputs = task.outputs;\nif (outputs == null || outputs === 'auto') throw new Error('declare outputs explicitly, or outputs = []');","typeGuard":"function hasExplicitOutputs(t: { outputs?: string[] | 'auto' }): t is { outputs: string[] } {\n  return Array.isArray(t.outputs);\n}","tryCatchPattern":null,"preventionTips":["Always declare outputs (or outputs = []) on cacheable tasks","Don't rely on auto output discovery when caching is enabled","Lint mise.toml task blocks for the outputs key in code review"],"tags":["task-cache","config-validation","mise-toml"],"backgroundTag":"missing-required-config-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"}