{"record":{"id":"ae994403e396cef8","repo":"jdx/mise","slug":"remote-mise-candidate-discovery-returned-a-truncat","errorCode":null,"errorMessage":"remote mise candidate discovery returned a truncated response","messagePattern":"remote mise candidate discovery returned a truncated response","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/remote.rs","lineNumber":1319,"sourceCode":"  case \"$1\" in\n    /*) if [ -x \"$1\" ]; then printf '%s\\000' \"$1\"; fi ;;\n  esac\n}\nold_ifs=$IFS\nIFS=:\nfor directory in $PATH; do\n  if [ -z \"$directory\" ]; then directory=.; fi\n  emit_mise_candidate \"$directory/mise\"\ndone\nIFS=$old_ifs\nfor candidate in \"$HOME/.local/bin/mise\" \"$HOME/.local/share/mise/bin/mise\" \"$HOME/.cargo/bin/mise\" /usr/local/bin/mise /opt/homebrew/bin/mise; do\n  emit_mise_candidate \"$candidate\"\ndone\"#\n}\n\nfn parse_remote_mise_candidates(output: &str) -> Result<Vec<String>> {\n    if !output.is_empty() && !output.ends_with('\\0') {\n        bail!(\"remote mise candidate discovery returned a truncated response\");\n    }\n    output\n        .split_terminator('\\0')\n        .map(validated_remote_command)\n        .collect::<Result<IndexSet<_>>>()\n        .map(IndexSet::into_iter)\n        .map(Iterator::collect)\n}\n\n#[derive(Clone, Debug, Eq, PartialEq)]\nstruct RemoteMiseIdentity {\n    version: String,\n    fingerprint: String,\n}\n\nasync fn remote_mise_candidate_identities(\n    session: &SshSession<'_>,\n    candidates: &[String],","sourceCodeStart":1301,"sourceCodeEnd":1337,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/remote.rs#L1301-L1337","documentation":"When mise discovers mise executables on a remote host it runs a shell script that emits each candidate path followed by a NUL byte (\\0). After collecting the output, parse_remote_mise_candidates requires that non-empty output end with a NUL terminator; if it does not, the response was cut off mid-write (partial command output, connection drop, or interleaved output) and the candidate list cannot be trusted, so this error is thrown.","triggerScenarios":"Calling remote mise candidate discovery (which runs remote_mise_candidates_script over SSH) when the remote shell output is truncated: the SSH session closes mid-command, output buffering drops the final NUL, or another process wrote a partial candidate entry.","commonSituations":"Flaky SSH connections to remote hosts; remote shells with output limits (ulimit/stty) that truncate command output; proxies or wrappers around SSH that mangle binary-safe NUL-delimited output; very slow remote hosts where the session times out during discovery.","solutions":["Re-run the operation; transient SSH truncation usually resolves on retry","Verify the SSH connection is stable (no proxy/timeout dropping the session mid-output)","Ensure no wrapper around the remote shell (e.g. motd scripts, rc files printing partial output) interferes with NUL-delimited output","Set remote_mise or mise_bin explicitly to skip candidate discovery entirely"],"exampleFix":"// before (implicit discovery over unstable link)\nlet mise = system.remote_mise()?;\n// after\nlet mise = system.remote_mise().with_config(RemoteConfig::new().mise_bin(\"/usr/local/bin/mise\"))?;","handlingStrategy":"retry","validationCode":"let out = ssh_output; if !out.is_empty() && !out.ends_with('\\0') { /* treat as truncated, retry */ }","typeGuard":"fn is_complete_candidate_output(output: &str) -> bool { output.is_empty() || output.ends_with('\\0') }","tryCatchPattern":"match result { Err(e) if e.to_string().contains(\"truncated response\") => retry_with_backoff(3), Err(e) => return Err(e), Ok(v) => v }","preventionTips":["Use stable, non-timeout-prone SSH connections for remote discovery","Avoid shell rc scripts that emit partial output into non-interactive sessions","Prefer explicit remote_mise/mise_bin config over output-scraping discovery on unreliable hosts"],"tags":["remote","ssh","truncated-output"],"backgroundTag":"unexpected-response-shape","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"}