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

fix: make indexer errors attestable when subgraphError:allow is enabled #5609

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions graph/src/data/query/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::sync::Arc;

use crate::data::subgraph::*;
use crate::prelude::q;
use crate::{components::store::StoreError, prelude::CacheWeight};
use crate::{components::store::StoreError, prelude::CacheWeight, schema::ErrorPolicy};

#[derive(Debug, Clone)]
pub struct CloneableAnyhowError(Arc<anyhow::Error>);
Expand Down Expand Up @@ -350,15 +350,23 @@ pub enum QueryError {
EncodingError(FromUtf8Error),
ParseError(Arc<anyhow::Error>),
ExecutionError(QueryExecutionError),
IndexingError,
IndexingError { subgraph_error_allowed: bool },
}

impl QueryError {
pub fn is_attestable(&self) -> bool {
match self {
QueryError::EncodingError(_) | QueryError::ParseError(_) => true,
QueryError::ExecutionError(err) => err.is_attestable(),
QueryError::IndexingError => false,
QueryError::IndexingError {
subgraph_error_allowed,
} => *subgraph_error_allowed || false,
}
}

pub fn indexing_error_with_policy(policy: ErrorPolicy) -> Self {
QueryError::IndexingError {
subgraph_error_allowed: matches!(policy, ErrorPolicy::Allow),
}
}
}
Expand Down Expand Up @@ -397,7 +405,9 @@ impl fmt::Display for QueryError {
QueryError::ParseError(ref e) => write!(f, "{}", e),

// This error message is part of attestable responses.
QueryError::IndexingError => write!(f, "indexing_error"),
QueryError::IndexingError {
subgraph_error_allowed: _,
} => write!(f, "indexing_error"),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion graphql/src/store/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ impl Resolver for StoreResolver {

// Add the "indexing_error" to the response.
assert!(result.errors_mut().is_empty());
*result.errors_mut() = vec![QueryError::IndexingError];
*result.errors_mut() = vec![QueryError::indexing_error_with_policy(self.error_policy)];

match self.error_policy {
// If indexing errors are denied, we omit results, except for the `_meta` response.
Expand Down
Loading