Skip to content

Commit

Permalink
fix: remove obsolete handling for indexer-service error
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Jan 2, 2025
1 parent e2a3937 commit c3f834d
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/indexer_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use thegraph_core::{
},
attestation::{self, Attestation},
};
use thegraph_graphql_http::http::response::Error as GQLError;
use url::Url;

use crate::{
Expand Down Expand Up @@ -146,19 +145,18 @@ impl IndexerClient {
}
}

fn rewrite_response(
response: &str,
) -> Result<(String, Vec<GQLError>, Option<Block>), IndexerError> {
#[derive(Deserialize, Serialize)]
struct Error {
message: String,
}

fn rewrite_response(response: &str) -> Result<(String, Vec<Error>, Option<Block>), IndexerError> {
#[derive(Deserialize, Serialize)]
struct Response {
data: Option<ProbedData>,
#[serde(default)]
#[serde(skip_serializing_if = "Vec::is_empty")]
errors: Vec<GQLError>,
// indexer-service sometimes returns errors in this form, which isn't ideal
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
error: Option<String>,
errors: Vec<Error>,
}
#[derive(Deserialize, Serialize)]
struct ProbedData {
Expand All @@ -180,14 +178,6 @@ fn rewrite_response(
let mut payload: Response =
serde_json::from_str(response).map_err(|err| BadResponse(err.to_string()))?;

if let Some(err) = payload.error.take() {
payload.errors.push(GQLError {
message: err,
locations: Default::default(),
path: Default::default(),
});
}

// Avoid processing oversized errors.
for err in &mut payload.errors {
err.message.truncate(256);
Expand Down

0 comments on commit c3f834d

Please sign in to comment.