Skip to content

Commit 344fad3

Browse files
committed
graph: Prevent duplicate source subgraphs in manifest validation
1 parent 0260db4 commit 344fad3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

graph/src/data/subgraph/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,23 @@ impl<C: Blockchain> UnvalidatedSubgraphManifest<C> {
719719
));
720720
}
721721

722+
// Check for duplicate source subgraphs
723+
let mut seen_sources = std::collections::HashSet::new();
724+
for ds in data_sources.iter() {
725+
if let DataSource::Subgraph(ds) = ds {
726+
let source_id = ds.source.address();
727+
if !seen_sources.insert(source_id.clone()) {
728+
errors.push(SubgraphManifestValidationError::DataSourceValidation(
729+
"subgraph".to_string(),
730+
anyhow!(
731+
"Multiple subgraph datasources cannot use the same source subgraph {}",
732+
source_id
733+
),
734+
));
735+
}
736+
}
737+
}
738+
722739
errors
723740
}
724741

0 commit comments

Comments
 (0)