{"record":{"id":"a5901b082a9ebe0e","repo":"neondatabase/neon","slug":"invalid-host","errorCode":null,"errorMessage":"Invalid host","messagePattern":"Invalid host","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compute_tools/src/rsyslog.rs","lineNumber":121,"sourceCode":"    })?;\n\n    let is_valid = url.scheme() == \"http\"\n        && url.path() == \"/\"\n        && url.query().is_none()\n        && url.fragment().is_none()\n        && url.username() == \"\"\n        && url.password().is_none();\n\n    if !is_valid {\n        return Err(anyhow!(\n            \"Invalid address format {remote_endpoint}, expected host:port\"\n        ));\n    }\n    let host = match url.host() {\n        Some(Host::Domain(h)) if hostname_validator::is_valid(h) => h.to_string(),\n        Some(Host::Ipv4(ip4)) => ip4.to_string(),\n        Some(Host::Ipv6(ip6)) => ip6.to_string(),\n        _ => return Err(anyhow!(\"Invalid host\")),\n    };\n    let port = url\n        .port()\n        .ok_or_else(|| anyhow!(\"Invalid port in {remote_endpoint}\"))?;\n\n    Ok((host, port, tls))\n}\n\nfn generate_audit_rsyslog_config(\n    log_directory: String,\n    endpoint_id: &str,\n    project_id: &str,\n    remote_syslog_host: &str,\n    remote_syslog_port: u16,\n    remote_syslog_tls: &str,\n) -> String {\n    format!(\n        include_str!(\"config_template/compute_audit_rsyslog_template.conf\"),","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/neondatabase/neon/blob/8f60b04da47ffefe0e52bda2440134b42874eb75/compute_tools/src/rsyslog.rs#L103-L139","documentation":"After URL parsing and the structural checks, the host component itself is unusable: url.host() is None (input was port-only like ':5555'), or it is a domain failing hostname_validator::is_valid (leading hyphen '-collector.host.tld', underscores, overlong labels), or another non-IP host form the match does not accept. Only valid domains, IPv4 and IPv6 literals pass.","triggerScenarios":"Input ':5555' (empty host), '-collector.host.tld:5555' (invalid hostname), hosts with underscores or other characters forbidden by RFC hostname rules.","commonSituations":"Internal hostnames containing underscores (common in k8s service names hand-written by users); typos adding leading dashes; empty host values paired with a port.","solutions":["Use a syntactically valid hostname (alphanumeric plus hyphens, no leading/trailing hyphen) or an IP literal","If the real host has underscores or exotic characters, reference it by IP address instead","Ensure the host part is non-empty when a port is present"],"exampleFix":"# before\nAUDIT_LOGGING_ENDPOINT=-collector.host.tld:5555\n\n# after\nAUDIT_LOGGING_ENDPOINT=collector.host.tld:5555","handlingStrategy":"validation","validationCode":"// check hostname validity before configure_audit_rsyslog\nif !hostname_validator::is_valid(host) {\n    bail!(\"audit endpoint host {host:?} is not a valid hostname; use a valid domain or an IP literal\");\n}","typeGuard":"fn is_valid_host(host: &str) -> bool {\n    hostname_validator::is_valid(host)\n        || host.parse::<std::net::Ipv4Addr>().is_ok()\n        || host.parse::<std::net::Ipv6Addr>().is_ok()\n}","tryCatchPattern":"let host = match url.host() {\n    Some(Host::Domain(h)) if hostname_validator::is_valid(h) => h.to_string(),\n    Some(Host::Ipv4(ip4)) => ip4.to_string(),\n    Some(Host::Ipv6(ip6)) => ip6.to_string(),\n    _ => return Err(anyhow!(\"Invalid host\")),\n};","preventionTips":["Use RFC-valid hostnames (no underscores, no leading/trailing hyphens) or IP literals","Validate the host half of every endpoint at config-ingestion time","Prefer IP literals when internal names contain unusual characters"],"tags":["hostname","validation","host-port","rsyslog","rust"],"backgroundTag":"invalid-hostname","analyzedSha":"8f60b04da47ffefe0e52bda2440134b42874eb75","analyzedAt":"2026-08-16T23:39:28.135Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}