{"record":{"id":"d1c3e2dfbcac428a","repo":"risingwavelabs/risingwave","slug":"can-t-get-be-host-from-url","errorCode":null,"errorMessage":"Can't get be host from url","messagePattern":"Can't get be host from url","errorType":"exception","errorClass":"SinkError","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/doris_starrocks_connector.rs","lineNumber":204,"sourceCode":"    match resp.status() {\n        StatusCode::TEMPORARY_REDIRECT => {\n            let be_url = resp\n                .headers()\n                .get(\"location\")\n                .ok_or_else(|| {\n                    SinkError::DorisStarrocksConnect(anyhow!(\"Can't get doris BE url in header\",))\n                })?\n                .to_str()\n                .context(\"Can't get doris BE url in header\")\n                .map_err(SinkError::DorisStarrocksConnect)?\n                .to_owned();\n\n            let mut parsed_be_url = Url::parse(&be_url)\n                .map_err(|err| SinkError::DorisStarrocksConnect(anyhow!(err)))?;\n\n            if fe_host != LOCALHOST && fe_host != LOCALHOST_IP {\n                let be_host = parsed_be_url.host_str().ok_or_else(|| {\n                    SinkError::DorisStarrocksConnect(anyhow!(\"Can't get be host from url\"))\n                })?;\n\n                if be_host == LOCALHOST || be_host == LOCALHOST_IP {\n                    // if be host is 127.0.0.1, we may can't connect to it directly,\n                    // so replace it with fe host\n                    parsed_be_url\n                        .set_host(Some(fe_host))\n                        .map_err(|err| SinkError::DorisStarrocksConnect(anyhow!(err)))?;\n                }\n            }\n            Ok(Some(parsed_be_url))\n        }\n        StatusCode::OK => {\n            // Some of the `StarRocks` transactional APIs will respond directly from FE. For example,\n            // the request to `/api/transaction/commit` endpoint does not seem to redirect to BE.\n            // In this case, the request should be treated as finished.\n            Ok(None)\n        }","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/doris_starrocks_connector.rs#L186-L222","documentation":"After parsing the BE redirect URL, the connector needs the BE host to apply a localhost-rewrite rule (a BE advertising 127.0.0.1 is replaced with the FE host). If Url::parse succeeded but host_str() returns None, the URL has no host component and this error is thrown.","triggerScenarios":"The Doris FE's 307 location header contains a URL without a host (e.g. a relative path or malformed absolute URL) while the FE host itself is not localhost.","commonSituations":"Doris misconfiguration advertising bad BE addresses; custom DNS/ingress setups returning odd redirects; corrupted location headers.","solutions":["Inspect the Location header returned by the FE and ensure it is a full URL with host.","Fix BE `heartbeat_service_port`/advertised address configuration in Doris so redirects use proper hostnames.","Connect to the FE directly rather than through a rewriting proxy."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"fn url_has_host(u: &str) -> bool {\n    url::Url::parse(u).ok().and_then(|u| u.host_str().map(|_| true)).unwrap_or(false)\n}","tryCatchPattern":"match try_get_be_url(resp).await {\n    Err(SinkError::DorisStarrocksConnect(e)) if e.to_string().contains(\"Can't get be host from url\") => {\n        eprintln!(\"BE redirect URL missing host: {e}\");\n    }\n    other => other?,\n}","preventionTips":["Fix Doris BE advertised addresses so redirects contain absolute URLs with hosts.","Avoid rewriting proxies in front of the FE that mangle redirects.","Log the raw Location header when debugging."],"tags":["rust","sink","doris","http","url"],"backgroundTag":"invalid-url","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}