-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
fossil-headers-db/src/rpc/mod.rs
Line 162 in 522f4a5
| Ok(response) => response, |
Description:
The current implementation of make_rpc_call does not verify the HTTP status code after receiving a response. This may result in processing error responses (e.g., 4xx or 5xx statuses) as if they were successful, leading to misleading error handling and deserialization issues.
Steps to Reproduce:
- Call the RPC endpoint with conditions that force an error HTTP status (e.g., simulate a 500 Internal Server Error).
- Observe that the code proceeds to attempt deserialization without checking the response status.
Expected Behavior:
- The function should verify that the HTTP response status is successful (e.g., using
response.status().is_success()) before processing the body. - In case of a non-success status, the function should log the error and return an appropriate error message.
Proposed Fix:
Modify the make_rpc_call function to include a check on the HTTP response status. For example:
let raw_response = match raw_response {
Ok(response) => {
if !response.status().is_success() {
error!("Received unsuccessful HTTP status: {:?}", response.status());
return Err(eyre!("Unsuccessful HTTP response status: {:?}", response.status()));
}
response
}
Err(e) => {
error!("HTTP request error: {:?}", e);
return Err(e.into());
}
};Impact:
Implementing this change will improve error handling and prevent the misinterpretation of error responses, leading to more robust and predictable behavior when interacting with the RPC service.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels