{"record":{"id":"9c892aede4799be9","repo":"jdx/mise","slug":"task-cache-requires-at-least-one-source","errorCode":null,"errorMessage":"task {} cache requires at least one source","messagePattern":"task (.+?) cache requires at least one source","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/task/task_cache.rs","lineNumber":1203,"sourceCode":"    display_cache_text(&crate::file::display_path(path))\n}\n\nfn display_cache_text(text: &str) -> String {\n    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        );","sourceCodeStart":1185,"sourceCodeEnd":1221,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/task/task_cache.rs#L1185-L1221","documentation":"validate_config enforces that any task using artifact caching declares at least one source file. The cache key is derived from source inputs, so a task with no sources has nothing to fingerprint and cannot be cached safely. The task name is included in the message to pinpoint the offending config.","triggerScenarios":"Calling task cache setup/validate_config for a task whose `sources` list is empty (or unset) while caching is enabled for it (e.g. cache_experiment/cache settings apply to the task).","commonSituations":"Writing a mise.toml task with cache enabled but forgetting sources = [...]; a task whose sources were removed during refactoring; generated tasks that omit sources.","solutions":["Add at least one source to the task, e.g. sources = [\"src/**/*.ts\"].","If the task genuinely has no inputs, disable artifact caching for it.","Check the task name in the message and fix the corresponding mise.toml entry.","Run `mise tasks info <task>` to inspect the resolved task config."],"exampleFix":"// before (mise.toml)\n[tasks.build]\nrun = \"vite build\"\ncache = { outputs = [\"dist\"] }\n// after\n[tasks.build]\nrun = \"vite build\"\nsources = [\"src/**/*\"]\ncache = { outputs = [\"dist\"] }","handlingStrategy":"validation","validationCode":"# shell: check task config before running\nmise tasks info build | grep -q 'sources' || echo 'task build lacks sources'\n# TOML: ensure at least one entry\nassert len(task.get('sources', [])) > 0, 'caching task needs sources'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair cache-enabled tasks with a sources = [...] list","Review tasks after refactors to confirm sources weren't dropped","Validate task configs in CI with `mise tasks info`"],"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"}