{"record":{"id":"aca3c6ab3cc16979","repo":"jdx/mise","slug":"at-least-one-target-or-changed-is-required","errorCode":null,"errorMessage":"at least one target or --changed is required","messagePattern":"at least one target or --changed is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/dotfiles/add.rs","lineNumber":101,"sourceCode":"\n    /// Prompt securely for missing bootstrap secret inputs\n    #[usage(long)]\n    pub(super) prompt_secrets: bool,\n}\n\nimpl DotfilesAdd {\n    /// Validate and capture the requested targets as one transactional update.\n    pub(crate) async fn run(self) -> Result<()> {\n        let mode = self.validate()?;\n        OperationScope::wrap(\"bootstrap dotfiles add\", self.dry_run, self.run_inner(mode)).await\n    }\n\n    fn validate(&self) -> Result<FileMode> {\n        if self.changed && !self.targets.is_empty() {\n            bail!(\"--changed does not accept target arguments\");\n        }\n        if !self.changed && self.targets.is_empty() {\n            bail!(\"at least one target or --changed is required\");\n        }\n        if self.source.is_some() && self.targets.len() != 1 {\n            bail!(\"--source can only be used with one target\");\n        }\n        match self.mode.as_deref() {\n            Some(\"track\") => bail!(\n                \"`--mode track` tracks a file where it is and takes no source; use `mise dot track <path>`\"\n            ),\n            Some(mode) => {\n                FileMode::parse(mode).ok_or_else(|| eyre::eyre!(\"unknown dotfile mode: {mode}\"))\n            }\n            None => Ok(system::files::default_mode()),\n        }\n    }\n\n    async fn run_inner(mut self, mode: FileMode) -> Result<()> {\n        let config = Config::get().await?;\n        let secrets = system::secrets::resolve(&config, self.prompt_secrets)?;","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/dotfiles/add.rs#L83-L119","documentation":"`mise dotfiles add` validation: the invocation passed neither any target paths nor --changed, so there is nothing to add and the command refuses to run an empty transaction rather than silently succeeding.","triggerScenarios":"Running `mise dotfiles add` with no positional targets and without `--changed` (changed == false && targets.is_empty()) in validate() called from run.","commonSituations":"Running the bare command to 'see what it does'; a script variable holding the target path expanding empty; forgetting --changed when intending to add all differing files.","solutions":["Pass at least one target: `mise dotfiles add ~/.zshrc`.","Use `mise dotfiles add --changed` to add all detected differing files.","If the path came from a variable, verify it is non-empty before invoking the command."],"exampleFix":"// before\n$ mise dotfiles add\n\n// after\n$ mise dotfiles add ~/.zshrc\n# or\n$ mise dotfiles add --changed","handlingStrategy":"validation","validationCode":"# shell-side guard: require at least one target or --changed\n[ $# -eq 0 ] && [ -z \"$CHANGED\" ] && { echo \"usage: dotfiles add [--changed] <target...>\" >&2; exit 2; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass an explicit target or --changed.","Check shell variables holding paths are non-empty before use.","Wrap add commands in scripts with usage checks."],"tags":["dotfiles","cli","validation","missing-argument"],"backgroundTag":"missing-required-argument","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"}