Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend::get_host() call generates Buffer length error #254

Closed
hrmsk66 opened this issue Apr 30, 2023 · 2 comments
Closed

Backend::get_host() call generates Buffer length error #254

hrmsk66 opened this issue Apr 30, 2023 · 2 comments

Comments

@hrmsk66
Copy link

hrmsk66 commented Apr 30, 2023

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/"
@fgsch
Copy link
Member

fgsch commented Oct 13, 2023

Are you still seeing this issue? I cannot reproduce it with Viceroy 0.9.1.

@joeshaw
Copy link
Member

joeshaw commented Oct 16, 2023

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.

@joeshaw joeshaw closed this as completed Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants