From 91366e3e56954ce7457b774cd7bcb10408909d10 Mon Sep 17 00:00:00 2001 From: Theo Butler Date: Thu, 21 Sep 2023 10:44:28 -0500 Subject: [PATCH] fix: add status code to UnattestableError --- graph-gateway/src/client_query.rs | 2 +- graph-gateway/src/indexer_client.rs | 5 +++-- graph-gateway/src/reports.rs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/graph-gateway/src/client_query.rs b/graph-gateway/src/client_query.rs index 1f0ca04f..d4dfa493 100644 --- a/graph-gateway/src/client_query.rs +++ b/graph-gateway/src/client_query.rs @@ -890,7 +890,7 @@ async fn handle_indexer_query_inner( weight: 35, }); tracing::info!(%error, "penalizing for unattestable error"); - return Err(IndexerError::UnattestableError); + return Err(IndexerError::UnattestableError(StatusCode::OK)); } } diff --git a/graph-gateway/src/indexer_client.rs b/graph-gateway/src/indexer_client.rs index 762f46d7..08934d60 100644 --- a/graph-gateway/src/indexer_client.rs +++ b/graph-gateway/src/indexer_client.rs @@ -1,6 +1,7 @@ use std::sync::Arc; use alloy_primitives::B256; +use axum::http::StatusCode; use serde::{Deserialize, Serialize}; use indexer_selection::{Selection, UnresolvedBlock}; @@ -21,7 +22,7 @@ pub struct ResponsePayload { pub enum IndexerError { NoAllocation, NoAttestation, - UnattestableError, + UnattestableError(StatusCode), Timeout, UnexpectedPayload, UnresolvedBlock, @@ -91,7 +92,7 @@ impl IndexerClient { tracing::trace!(response_status = ?err.status()); return match err.status() { Some(status) if status.is_server_error() => { - Err(IndexerError::UnattestableError) + Err(IndexerError::UnattestableError(status)) } _ => Err(IndexerError::Other(err.to_string())), }; diff --git a/graph-gateway/src/reports.rs b/graph-gateway/src/reports.rs index 2fdd26ef..35ddd131 100644 --- a/graph-gateway/src/reports.rs +++ b/graph-gateway/src/reports.rs @@ -500,7 +500,7 @@ pub fn indexer_attempt_status_code(result: &Result (0x0, 200_u32.to_be()), Err(IndexerError::NoAttestation) => (0x1, 0x0), - Err(IndexerError::UnattestableError) => (0x2, 0x0), + Err(IndexerError::UnattestableError(_)) => (0x2, 0x0), Err(IndexerError::Timeout) => (0x3, 0x0), Err(IndexerError::UnexpectedPayload) => (0x4, 0x0), Err(IndexerError::UnresolvedBlock) => (0x5, 0x0),