vectordotdev/vector · error
HTTP status codes are valid u16 values
Error message
HTTP status codes are valid u16 values
What it means
During the Keep sink healthcheck, the response's http::StatusCode is converted back into the local StatusCode type via StatusCode::from_u16 and unwrapped with expect. Because res.status().as_u16() already produced a valid HTTP status code, the conversion cannot fail; the expect documents that invariant. Hitting this panic indicates a malformed internal HTTP layer rather than a server problem.
Solutions
- Inspect any proxies/middlewares rewriting HTTP responses between Vector and Keep.
- Update the HTTP client dependency (reqwest/hyper) to a version that guarantees valid status codes.
- Confirm Keep returns standard HTTP status codes (200/202/400 are handled explicitly).
Defensive patterns
Strategy: fallback
Try / catch
// keep proxies from rewriting status lines; on healthcheck failure, alert and retry // systemd auto-restart keeps the pipeline alive Restart=on-failure
Prevention
- Keep Keep behind proxies that pass through standard HTTP status codes.
- Use stock http client dependency versions.
- Monitor healthcheck logs for anomalies.
When it happens
Trigger: Healthcheck receives a response whose status code, when re-parsed via StatusCode::from_u16, is invalid — only possible if the HTTP client returned a fabricated non-standard status code outside 100..=599.
Common situations: Buggy or patched HTTP client/proxy in front of Keep injecting invalid status lines; effectively unreachable on stock builds since hyper/reqwest already validate status codes.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- building HTTP request failed unexpectedly
- Building request never fails.
- a valid HTTP/1 URI is valid as an HTTP URI
- a validated HTTP endpoint is a valid `http 1` URI
- Could not convert HTTP status code to JSON
AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16).
Data as JSON: /api/errors/0d44f591bd790539.
Report an issue: GitHub.
Appendix: source
Thrown at src/sinks/keep/config.rs:188
}
async fn healthcheck(
endpoint: HttpEndpoint,
api_key: SensitiveString,
client: HttpClient,
) -> crate::Result<()> {
let request =
Request::post(endpoint.into_v1()).header(HTTP_HEADER_KEEP_API_KEY, api_key.inner());
let body = crate::serde::json::to_bytes(&Vec::<BoxedRawValue>::new())
.unwrap()
.freeze();
let req: Request<Bytes> = request.body(body)?;
let req = req.map(full_body);
let res = client.send(req).await?;
let status = StatusCode::from_u16(res.status().as_u16())
.expect("HTTP status codes are valid u16 values");
let body = res.into_body().collect().await?.to_bytes();
match status {
StatusCode::OK => Ok(()), // Healthcheck passed
StatusCode::BAD_REQUEST => Ok(()), // Healthcheck failed due to client error but is still considered valid
StatusCode::ACCEPTED => Ok(()), // Consider healthcheck passed if server accepted request
StatusCode::UNAUTHORIZED => {
// Handle unauthorized errors
let json: serde_json::Value = serde_json::from_slice(&body[..])?;
let message = json
.as_object()
.and_then(|o| o.get("error"))
.and_then(|s| s.as_str())
.unwrap_or("Token is not valid, 401 returned.")
.to_string();
Err(message.into())
}
_ => {View on GitHub (pinned to bdb87aeaa4)