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

Add more logging for Help proxy errors #654

Merged
merged 3 commits into from
Dec 12, 2024
Merged

Conversation

juliasilge
Copy link
Contributor

@juliasilge juliasilge commented Dec 11, 2024

Addresses posit-dev/positron#3543 by adding some more logging for us to see more detail in what is going on

This PR moves return HttpResponse::BadGateway().finish() from where it is now to after some logging we would do anyway, and then also adds logging for the error case (the status code plus just the whole body).

// Get the headers we need.
let headers = response.headers().clone();
let content_type = headers.get("content-type");

// Log.
log::info!(
"Proxying URL '{:?}' path '{}' content-type is '{:?}'",
"Proxying URL {:?} path '{}' content-type is '{:?}'",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See how these URLs look in the logs now (too many quotes):
posit-dev/positron#3543 (comment)

"Got status {} proxying {:?}: {:?}",
response.status().clone().to_string(),
target_url.to_string(),
response.text().await.unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since something is wrong in this code path, can we confidently say that response can be properly decoded? Might be better to condition this on Ok()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed about the unwrap() feeling unsafe here since we are in a != reqwest::StatusCode::OK state here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, both! Improved in a85e592

"Got status {} proxying {:?}: {:?}",
response.status().clone().to_string(),
target_url.to_string(),
response.text().await.unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed about the unwrap() feeling unsafe here since we are in a != reqwest::StatusCode::OK state here

@juliasilge juliasilge merged commit 7a0acf9 into main Dec 12, 2024
6 checks passed
@juliasilge juliasilge deleted the more-help-proxy-logging branch December 12, 2024 18:09
@github-actions github-actions bot locked and limited conversation to collaborators Dec 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants