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: add miscategorized store error to attestable filter #361

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 3 additions & 11 deletions graph-gateway/src/client_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ use crate::{
receipts::{ReceiptPools, ReceiptStatus},
reports,
topology::{Deployment, GraphNetwork, Subgraph},
unattestable_errors::{
MISCATEGORIZED_ATTESTABLE_ERROR_MESSAGE_FRAGMENTS, UNATTESTABLE_ERROR_MESSAGE_FRAGMENTS,
},
unattestable_errors::{miscategorized_attestable, miscategorized_unattestable},
};

fn query_id() -> String {
Expand Down Expand Up @@ -836,10 +834,7 @@ async fn handle_indexer_query_inner(
}

for error in &indexer_errors {
if UNATTESTABLE_ERROR_MESSAGE_FRAGMENTS
.iter()
.any(|err| error.contains(err))
{
if miscategorized_unattestable(error) {
let _ = ctx.observations.write(Update::Penalty {
indexing: selection.indexing,
weight: 35,
Expand All @@ -858,10 +853,7 @@ async fn handle_indexer_query_inner(
// TODO: This is a temporary hack to handle errors that were previously miscategorized as
// unattestable in graph-node.
for error in &indexer_errors {
if MISCATEGORIZED_ATTESTABLE_ERROR_MESSAGE_FRAGMENTS
.iter()
.any(|err| error.contains(err))
{
if miscategorized_attestable(error) {
return Ok(response.payload);
}
}
Expand Down
16 changes: 15 additions & 1 deletion graph-gateway/src/unattestable_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,22 @@ pub const UNATTESTABLE_ERROR_MESSAGE_FRAGMENTS: [&str; 18] = [
// Note: The linked PRs may be merged. But these must still be special-cased unless the minimum
// indexer version includes these fixes.
#[rustfmt::skip]
pub const MISCATEGORIZED_ATTESTABLE_ERROR_MESSAGE_FRAGMENTS: [&str; 3] = [
pub const MISCATEGORIZED_ATTESTABLE_ERROR_MESSAGE_FRAGMENTS: [&str; 4] = [
"Null value resolved for non-null field", // NonNullError (https://github.com/graphprotocol/graph-node/pull/3507)
"Failed to decode", // ValueParseError (https://github.com/graphprotocol/graph-node/pull/4278)
"Failed to coerce value", // EnumCoercionError, ScalarCoercionError (https://github.com/graphprotocol/graph-node/pull/4278)
"Child filters can not be nested", // StoreError (https://github.com/graphprotocol/graph-node/issues/4775)
];

pub fn miscategorized_unattestable(error: &str) -> bool {
let unattestable = UNATTESTABLE_ERROR_MESSAGE_FRAGMENTS
.iter()
.any(|err| error.contains(err));
unattestable && !miscategorized_attestable(error)
}

pub fn miscategorized_attestable(error: &str) -> bool {
MISCATEGORIZED_ATTESTABLE_ERROR_MESSAGE_FRAGMENTS
.iter()
.any(|err| error.contains(err))
}