cloudflare / pingora

A library for building fast, reliable and evolvable network services.
Apache License 2.0
20.28k stars 1.1k forks source link

String interpolation used outside of the context of `format!()` #181

Closed jamesmunns closed 2 months ago

jamesmunns commented 3 months ago

https://github.com/cloudflare/pingora/blob/5fdf287c4d6a9ddc8a9caf3447cd27575c13a24c/pingora-core/src/listeners/tls.rs#L59-L74

In these lines, the string contents are not interpolated, so I see this on the command line:

thread 'main' panicked at src/main.rs:29:67:
called `Result::unwrap()` on an `Err` value: Error { etype: Custom("TLSConfigError"), esource: Unset, retry: Decided(false), cause: Some(ErrorStack([Error { code: 2147483650, library: "system library", function: "file_ctrl", file: "crypto/bio/bss_file.c", line: 297, data: "calling fopen(./assets/test.pem, r)" }, Error { code: 268959746, library: "BIO routines", function: "file_ctrl", reason: "system lib", file: "crypto/bio/bss_file.c", line: 300 }, Error { code: 168296450, library: "SSL routines", function: "SSL_CTX_use_PrivateKey_file", reason: "system lib", file: "ssl/ssl_rsa.c", line: 386 }])), context: Some(Static("fail to read key file {key_path}")) }

Specifically:

context: Some(Static("fail to read key file {key_path}"))
jamesmunns commented 3 months ago

The correct syntax for this would be something like:

.or_err(TLS_CONF_ERR, &format!("fail to read key file {key_path}"))
gumpt commented 2 months ago

This should be fixed with commit e6f2cb0.