Skip to content

Commit

Permalink
fix: make indexer errors attestable when is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
dwerner committed Aug 19, 2024
1 parent e2e6925 commit c8025ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 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 indexer_error_with_policy(policy: ErrorPolicy) -> Self {
QueryError::IndexingError {
subgraph_error_allowed: matches!(policy, ErrorPolicy::Allow),
}
}
}
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::indexer_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

0 comments on commit c8025ac

Please sign in to comment.