Skip to content

Commit

Permalink
graph: Prevent duplicate source subgraphs in manifest validation
Browse files Browse the repository at this point in the history
  • Loading branch information
incrypto32 committed Feb 11, 2025
1 parent 0260db4 commit 344fad3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions graph/src/data/subgraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,23 @@ impl<C: Blockchain> UnvalidatedSubgraphManifest<C> {
));
}

// Check for duplicate source subgraphs
let mut seen_sources = std::collections::HashSet::new();
for ds in data_sources.iter() {
if let DataSource::Subgraph(ds) = ds {
let source_id = ds.source.address();
if !seen_sources.insert(source_id.clone()) {
errors.push(SubgraphManifestValidationError::DataSourceValidation(
"subgraph".to_string(),
anyhow!(
"Multiple subgraph datasources cannot use the same source subgraph {}",
source_id
),
));
}
}
}

errors
}

Expand Down

0 comments on commit 344fad3

Please sign in to comment.