@secondlayer/subgraphs 3.24.2 → 3.24.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/index.js CHANGED
@@ -1842,6 +1842,7 @@ function matchSources(sources, transactions, events, traitContracts = new Map, f
1842
1842
  }
1843
1843
 
1844
1844
  // src/runtime/block-processor.ts
1845
+ import { secretsKeyAvailable } from "@secondlayer/shared/crypto/secrets";
1845
1846
  import { getTargetDb } from "@secondlayer/shared/db";
1846
1847
  import { resolveTraitContractIds } from "@secondlayer/shared/db/queries/contracts";
1847
1848
  import { advanceOperationCursor } from "@secondlayer/shared/db/queries/subgraph-operations";
@@ -2779,12 +2780,22 @@ async function refreshMatcher(db) {
2779
2780
 
2780
2781
  // src/runtime/block-processor.ts
2781
2782
  var routeCache = new Map;
2783
+
2784
+ class ByoKeyUnavailableError extends Error {
2785
+ constructor(subgraphName) {
2786
+ super(`subgraph ${subgraphName} is BYO (database_url_enc set) but this process has no SECONDLAYER_SECRETS_KEY — the subgraph processor deliberately does not hold it (f072). Route BYO subgraphs to a process that does, or unset BYO.`);
2787
+ this.name = "ByoKeyUnavailableError";
2788
+ }
2789
+ }
2782
2790
  async function resolveRoute(subgraphName, targetDb) {
2783
2791
  const cached = routeCache.get(subgraphName);
2784
2792
  if (cached)
2785
2793
  return cached;
2786
2794
  const row = await targetDb.selectFrom("subgraphs").selectAll().where("name", "=", subgraphName).executeTakeFirst();
2787
2795
  const byo = row ? isByoSubgraph(row) : false;
2796
+ if (row && byo && !secretsKeyAvailable()) {
2797
+ throw new ByoKeyUnavailableError(subgraphName);
2798
+ }
2788
2799
  const route = {
2789
2800
  schemaName: row?.schema_name ?? pgSchemaName(subgraphName),
2790
2801
  dataDb: row && byo ? resolveSubgraphDb(row) : targetDb,
@@ -5063,5 +5074,5 @@ export {
5063
5074
  ByoBreakingChangeError
5064
5075
  };
5065
5076
 
5066
- //# debugId=F67C948CCFE0BB8264756E2164756E21
5077
+ //# debugId=AD9497F805C348C364756E2164756E21
5067
5078
  //# sourceMappingURL=index.js.map