{"record":{"id":"2cb368a8fb488d9c","repo":"vectordotdev/vector","slug":"invalid-value-in-docker-host","errorCode":null,"errorMessage":"Invalid value in $DOCKER_HOST","messagePattern":"Invalid value in \\$DOCKER_HOST","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"vdev/src/testing/docker.rs","lineNumber":40,"sourceCode":"        if Command::new(tool)\n            .arg(\"version\")\n            .stdout(Stdio::null())\n            .stderr(Stdio::null())\n            .spawn()\n            .and_then(|mut child| child.wait())\n            .is_ok_and(|status| status.success())\n        {\n            return OsString::from(String::from(tool));\n        }\n    }\n    fatal!(\"No container tool could be detected.\");\n}\n\nfn detect_docker_socket() -> PathBuf {\n    match env::var_os(\"DOCKER_HOST\") {\n        Some(host) => host\n            .into_string()\n            .expect(\"Invalid value in $DOCKER_HOST\")\n            .strip_prefix(\"unix://\")\n            .expect(\"$DOCKER_HOST is not a socket path\")\n            .into(),\n        None => \"/var/run/docker.sock\".into(),\n    }\n}\n","sourceCodeStart":22,"sourceCodeEnd":47,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/vdev/src/testing/docker.rs#L22-L47","documentation":"vdev's detect_docker_socket reads the DOCKER_HOST environment variable and expects it to be valid UTF-8 (into_string().expect(\"Invalid value in $DOCKER_HOST\")) and then a unix:// socket path. If DOCKER_HOST is set to a non-UTF-8 value, the first expect panics; this is distinct from the follow-up panic for non-unix:// values. The function only supports local unix sockets, not TCP Docker hosts.","triggerScenarios":"Having DOCKER_HOST exported with non-UTF-8 bytes in the value (e.g. mangled by a shell/profile script), then running any vdev command that resolves the Docker socket.","commonSituations":"DOCKER_HOST set by tooling (docker-machine, docker context) with unexpected content; corrupted shell profile exporting garbage; copy-pasted value with invisible/non-UTF-8 characters.","solutions":["Inspect the variable: `printf '%s' \"$DOCKER_HOST\" | xxd` to spot invalid bytes, then unset it (`unset DOCKER_HOST`) to fall back to /var/run/docker.sock.","Set DOCKER_HOST to a clean value such as unix:///var/run/docker.sock.","Check ~/.bashrc, ~/.zshrc, or CI config for a script that writes a malformed DOCKER_HOST and fix it.","In code, replace the expect with from_utf8 handling on the OsString and a clear anyhow error, or support tcp:// hosts instead of assuming unix://."],"exampleFix":"// before\nSome(host) => host\n    .into_string()\n    .expect(\"Invalid value in $DOCKER_HOST\")\n// after\nSome(host) => host.into_string().map_err(|bad|\n    anyhow!(\"$DOCKER_HOST is not valid UTF-8: {:?}\", bad)\n)?","handlingStrategy":"validation","validationCode":"# before running vdev\npython3 -c \"import os,sys; v=os.environ.get('DOCKER_HOST',''); v.encode('utf-8'); sys.exit(0 if (not v or v.startswith('unix://')) else 1)\" || { echo 'DOCKER_HOST must be UTF-8 unix:// socket path'; exit 1; }","typeGuard":null,"tryCatchPattern":"match env::var_os(\"DOCKER_HOST\") {\n    Some(host) => match host.into_string() {\n        Ok(s) => /* proceed, validate unix:// prefix */,\n        Err(bad) => return Err(anyhow!(\"$DOCKER_HOST is not valid UTF-8: {:?}\", bad)),\n    },\n    None => /* default socket */,\n}","preventionTips":["Unset DOCKER_HOST to use the default /var/run/docker.sock when unsure.","Set DOCKER_HOST to unix:///var/run/docker.sock explicitly in profiles/CI.","Audit shell startup files and CI env exports for malformed values.","Remember this helper supports only unix sockets — avoid tcp:// values when using vdev."],"tags":["rust","vdev","docker","environment-variable","utf-8","panic"],"backgroundTag":"invalid-env-var-value","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}