{"record":{"id":"f3b1c0b8e9694b90","repo":"jdx/mise","slug":"remote-host-port-must-be-greater-than-zero","errorCode":null,"errorMessage":"remote host '{}' port must be greater than zero","messagePattern":"remote host '(.+?)' port must be greater than zero","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/remote.rs","lineNumber":326,"sourceCode":"\n    pub(crate) fn destination(&self) -> String {\n        match &self.user {\n            Some(user) => format!(\"{user}@{}\", self.host),\n            None => self.host.clone(),\n        }\n    }\n\n    fn validate(&self) -> Result<()> {\n        self.validate_with_source(true)\n    }\n\n    fn validate_with_source(&self, archive: bool) -> Result<()> {\n        validate_ssh_atom(\"host\", &self.host)?;\n        if let Some(user) = &self.user {\n            validate_ssh_atom(\"user\", user)?;\n        }\n        if self.port == Some(0) {\n            bail!(\"remote host '{}' port must be greater than zero\", self.name);\n        }\n        if archive && !self.source.is_dir() {\n            bail!(\n                \"remote host '{}' source is not a directory: {}\",\n                self.name,\n                self.source.display()\n            );\n        }\n        if archive && !self.copy_links {\n            for link in &self.copy_link {\n                validate_copy_link(&self.source, link).wrap_err_with(|| {\n                    format!(\"remote host '{}' has invalid copy_link\", self.name)\n                })?;\n            }\n        }\n        if let Some(identity) = &self.identity_file\n            && !identity.is_file()\n        {","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/remote.rs#L308-L344","documentation":"Remote host configuration validation rejects a port explicitly set to 0 for a remote target, since a zero port is meaningless for SSH/rsync. validate_with_source checks this for every remote host config during apply_overrides/validate.","triggerScenarios":"A remote host entry in configuration has `port = 0` (or is programmatically constructed with Some(0)); validate() or apply_overrides() then calls validate_with_source and bails.","commonSituations":"Copy-pasting config templates with placeholder 0 values; a templating/config generator that emits 0 when the real port is missing; editing TOML and typing 0 instead of deleting the key to use the SSH default (22).","solutions":["Remove the `port` key to use the SSH default (22).","Set the port to the actual listening port of the remote SSH server.","Check the config generator/template so it omits the key instead of emitting 0."],"exampleFix":"// before\n[[remote_host]]\nname = \"build-box\"\nport = 0\n// after\n[[remote_host]]\nname = \"build-box\"\nport = 2222","handlingStrategy":"validation","validationCode":"function validateRemoteHost(host) {\n  if (host.port !== undefined && (Number(host.port) <= 0 || !Number.isInteger(host.port))) {\n    throw new Error(`remote host '${host.name}' port must be greater than zero`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit the port key entirely to use SSH's default (22) rather than writing 0.","Validate host config at load time with a schema (positive integer port).","Template generators should drop unset ports instead of emitting placeholders."],"tags":["remote","ssh","configuration","validation"],"backgroundTag":"value-out-of-range","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"}