fix: improve error logging in indexer-proxy request handler#640
fix: improve error logging in indexer-proxy request handler#640cool-firer wants to merge 1 commit into
Conversation
- Add detailed error messages for different reqwest error types (timeout, connection, builder, redirect, status, request, body, decode) - Include HTTP status code in error messages when available - Bump utils version from 2.2.0 to 2.2.1 - Bump proxy version from 2.10.1 to 2.10.2 This helps diagnose service exceptions and network issues more effectively.
📝 WalkthroughWalkthroughVersion bumps applied to two Rust crate manifests in the indexer-proxy module, alongside enhanced error handling in the request module that provides detailed error categorization and specific messages for various failure scenarios instead of generic responses. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment Tip You can enable review details to help with troubleshooting, context usage and more.Enable the |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/indexer-proxy/utils/src/request.rs (1)
147-170: Reduce duplicated formatting and avoid dangling separators in error messages.This block works, but the repeated
format!branches increase maintenance cost and can emit messages ending with--when no status is present.♻️ Suggested cleanup
- Err(e) => { - let status_info = e.status() - .map(|s| format!(" (status: {})", s)) - .unwrap_or_default(); - - let error_msg = if e.is_timeout() { - format!("Service exception or timeout: {} -- {}", e, status_info) - } else if e.is_connect() { - format!("Service exception or Connection error: {} -- {}", e, status_info) - } else if e.is_builder() { - format!("Service exception or builder error: {} -- {}", e, status_info) - } else if e.is_redirect() { - format!("Service exception or redirect error: {} -- {}", e, status_info) - } else if e.is_status() { - format!("Service exception or status error: {} -- {}", e, status_info) - } else if e.is_request() { - format!("Service exception or request error: {} -- {}", e, status_info) - } else if e.is_body() { - format!("Service exception or body error: {} -- {}", e, status_info) - } else if e.is_decode() { - format!("Service exception or decode error: {} -- {}", e, status_info) - } else { - format!("Service exception: {} -- {}", e, status_info) - }; + Err(e) => { + let status_suffix = e + .status() + .map(|s| format!(" (status: {s})")) + .unwrap_or_default(); + + let category = if e.is_timeout() { + "timeout" + } else if e.is_connect() { + "connection" + } else if e.is_builder() { + "builder" + } else if e.is_redirect() { + "redirect" + } else if e.is_status() { + "status" + } else if e.is_request() { + "request" + } else if e.is_body() { + "body" + } else if e.is_decode() { + "decode" + } else { + "unknown" + }; + + let error_msg = format!("Service exception ({category}): {e}{status_suffix}"); return Err(Error::GraphQLInternal( 1010, error_msg, ))Also applies to: 174-174
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/indexer-proxy/utils/src/request.rs` around lines 147 - 170, In the Err(e) => block in request.rs, remove the duplicated format! branches by building the error-kind label once (based on e.is_timeout(), e.is_connect(), e.is_builder(), e.is_redirect(), e.is_status(), e.is_request(), e.is_body(), e.is_decode() — e.g., "timeout", "connect", "builder", etc.), then construct status_info only if e.status() is Some and append it with a separator (" -- ") only when present; finally call format!("Service exception{}: {}", optional_kind_prefix, e) or similar to produce a single message. Apply the same consolidation to the similar branch referenced around line 174 to avoid repeated formatting and trailing separators.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/indexer-proxy/utils/src/request.rs`:
- Around line 147-170: In the Err(e) => block in request.rs, remove the
duplicated format! branches by building the error-kind label once (based on
e.is_timeout(), e.is_connect(), e.is_builder(), e.is_redirect(), e.is_status(),
e.is_request(), e.is_body(), e.is_decode() — e.g., "timeout", "connect",
"builder", etc.), then construct status_info only if e.status() is Some and
append it with a separator (" -- ") only when present; finally call
format!("Service exception{}: {}", optional_kind_prefix, e) or similar to
produce a single message. Apply the same consolidation to the similar branch
referenced around line 174 to avoid repeated formatting and trailing separators.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2a0e309a-e327-4335-9c23-5f22fb40bbd2
📒 Files selected for processing (3)
apps/indexer-proxy/proxy/Cargo.tomlapps/indexer-proxy/utils/Cargo.tomlapps/indexer-proxy/utils/src/request.rs
This helps diagnose service exceptions and network issues more effectively.
Summary by CodeRabbit
Release Notes
Chores
Bug Fixes