From 1ae490d55fab0c957022300789cf6401e7e8dd63 Mon Sep 17 00:00:00 2001 From: shiyasmohd Date: Thu, 6 Mar 2025 15:50:00 +0530 Subject: [PATCH] graph: enhance err msg for source subgraph manifest resolution in composition --- graph/src/data_source/subgraph.rs | 33 ++++++++++++++----- .../tests/chain/ethereum/manifest.rs | 3 +- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/graph/src/data_source/subgraph.rs b/graph/src/data_source/subgraph.rs index 9e120a4c82c..b73b9e768c1 100644 --- a/graph/src/data_source/subgraph.rs +++ b/graph/src/data_source/subgraph.rs @@ -253,20 +253,32 @@ impl UnresolvedDataSource { let source_raw = resolver .cat(logger, &self.source.address.to_ipfs_link()) .await - .context("Failed to resolve source subgraph manifest")?; + .context(format!( + "Failed to resolve source subgraph [{}] manifest", + self.source.address, + ))?; - let source_raw: serde_yaml::Mapping = serde_yaml::from_slice(&source_raw) - .context("Failed to parse source subgraph manifest as YAML")?; + let source_raw: serde_yaml::Mapping = + serde_yaml::from_slice(&source_raw).context(format!( + "Failed to parse source subgraph [{}] manifest as YAML", + self.source.address + ))?; let deployment_hash = self.source.address.clone(); let source_manifest = UnresolvedSubgraphManifest::::parse(deployment_hash, source_raw) - .context("Failed to parse source subgraph manifest")?; + .context(format!( + "Failed to parse source subgraph [{}] manifest", + self.source.address + ))?; source_manifest .resolve(resolver, logger, LATEST_VERSION.clone()) .await - .context("Failed to resolve source subgraph manifest") + .context(format!( + "Failed to resolve source subgraph [{}] manifest", + self.source.address + )) .map(Arc::new) } @@ -292,12 +304,16 @@ impl UnresolvedDataSource { .iter() .any(|ds| matches!(ds, crate::data_source::DataSource::Subgraph(_))) { - return Err(anyhow!("Nested subgraph data sources are not supported.")); + return Err(anyhow!( + "Nested subgraph data sources [{}] are not supported.", + self.name + )); } if source_spec_version < &SPEC_VERSION_1_3_0 { return Err(anyhow!( - "Source subgraph manifest spec version {} is not supported, minimum supported version is {}", + "Source subgraph [{}] manifest spec version {} is not supported, minimum supported version is {}", + self.source.address, source_spec_version, SPEC_VERSION_1_3_0 )); @@ -310,7 +326,8 @@ impl UnresolvedDataSource { if pruning_enabled { return Err(anyhow!( - "Pruning is enabled for source subgraph, which is not supported" + "Pruning is enabled for source subgraph [{}], which is not supported", + self.source.address )); } diff --git a/store/test-store/tests/chain/ethereum/manifest.rs b/store/test-store/tests/chain/ethereum/manifest.rs index 9d094ae5817..49205c5f639 100644 --- a/store/test-store/tests/chain/ethereum/manifest.rs +++ b/store/test-store/tests/chain/ethereum/manifest.rs @@ -1852,7 +1852,8 @@ specVersion: 1.3.0 assert!(matches!(e, SubgraphManifestResolveError::ResolveError(_))); let error_msg = e.to_string(); println!("{}", error_msg); - assert!(error_msg.contains("Nested subgraph data sources are not supported.")); + assert!(error_msg + .contains("Nested subgraph data sources [SubgraphSource] are not supported.")); } } })