Backend::get_host() call generates Buffer length error
hrmsk66 opened this issue · 2 comments
When calling Backend::get_host() in the local test, the following error message is generated on the console:
(CLI version: v9.0.3, Viceroy version: 0.4.5)
2023-04-30T07:14:24.548437Z ERROR request{id=0}: Hostcall yielded an error: Buffer length error: host too long to fit in host.len()
Despite the error message, the hostname is still correctly retrieved, and there seem to be no functional issues.
The following code snippet can be used to reproduce the error:
# main.rs
use fastly::http::StatusCode;
use fastly::{Error, Request, Response, Backend};
#[fastly::main]
fn main(_req: Request) -> Result<Response, Error> {
let backend = Backend::from_name("httpbin").unwrap();
println!("{}", backend.get_host());
Ok(Response::from_status(StatusCode::OK))
}
# fastly.toml
# fastly.toml
[local_server]
[local_server.backends]
[local_server.backends.httpbin]
url = "https://httpbin.org/"
Are you still seeing this issue? I cannot reproduce it with Viceroy 0.9.1.
This message was to be expected -- there is a negotiation happening between the SDK and the runtime to figure out how big the buffer needs to be in order to hold the hostname. Basically the SDK is trying a too-small buffer with the hostcall once, getting that error back with the expected length, resizing the buffer to fit, and then calling the hostcall again successfully.
The message was misleading, and we changed the logging level of these messages so they now only display at DEBUG level. That was done in #314, which was included in v0.9.0.