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

Belt and braces on removal of url sensitive data from reqwest::Error #9

Merged
merged 3 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "google-generative-ai-rs"
version = "0.1.2"
version = "0.1.3"
edition = "2021"
authors = ["Mick Clarke <[email protected]>"]
license = "MIT"
Expand Down
9 changes: 7 additions & 2 deletions src/v1/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl Client {
let mut streamed_reponse = StreamedResponse {
streamed_candidates: vec![],
};
let mut response_stream = response.json_array_stream::<serde_json::Value>(2048);
let mut response_stream = response.json_array_stream::<serde_json::Value>(2048); //TODO what is a good length?
while let Some(json_value) =
response_stream
.try_next()
Expand Down Expand Up @@ -257,7 +257,12 @@ impl Client {
}
}
/// Creates a new error from a reqwest error.
fn new_error_from_reqwest_error(&self, e: reqwest::Error) -> GoogleAPIError {
fn new_error_from_reqwest_error(&self, mut e: reqwest::Error) -> GoogleAPIError {
if let Some(url) = e.url_mut() {
// Remove the API key from the URL, if any
url.query_pairs_mut().clear();
}

GoogleAPIError {
message: format!("{}", e),
code: e.status(),
Expand Down
Loading