@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.
@@ -1627,6 +1627,7 @@ function matchSources(sources, transactions, events, traitContracts = new Map, f
1627
1627
  }
1628
1628
 
1629
1629
  // src/runtime/block-processor.ts
1630
+ import { secretsKeyAvailable } from "@secondlayer/shared/crypto/secrets";
1630
1631
  import { getTargetDb } from "@secondlayer/shared/db";
1631
1632
  import { resolveTraitContractIds } from "@secondlayer/shared/db/queries/contracts";
1632
1633
  import { advanceOperationCursor } from "@secondlayer/shared/db/queries/subgraph-operations";
@@ -2564,12 +2565,22 @@ async function refreshMatcher(db) {
2564
2565
 
2565
2566
  // src/runtime/block-processor.ts
2566
2567
  var routeCache = new Map;
2568
+
2569
+ class ByoKeyUnavailableError extends Error {
2570
+ constructor(subgraphName) {
2571
+ 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.`);
2572
+ this.name = "ByoKeyUnavailableError";
2573
+ }
2574
+ }
2567
2575
  async function resolveRoute(subgraphName, targetDb) {
2568
2576
  const cached = routeCache.get(subgraphName);
2569
2577
  if (cached)
2570
2578
  return cached;
2571
2579
  const row = await targetDb.selectFrom("subgraphs").selectAll().where("name", "=", subgraphName).executeTakeFirst();
2572
2580
  const byo = row ? isByoSubgraph(row) : false;
2581
+ if (row && byo && !secretsKeyAvailable()) {
2582
+ throw new ByoKeyUnavailableError(subgraphName);
2583
+ }
2573
2584
  const route = {
2574
2585
  schemaName: row?.schema_name ?? pgSchemaName(subgraphName),
2575
2586
  dataDb: row && byo ? resolveSubgraphDb(row) : targetDb,
@@ -3558,5 +3569,5 @@ export {
3558
3569
  backfillSubgraph
3559
3570
  };
3560
3571
 
3561
- //# debugId=06DD68AD526188D464756E2164756E21
3572
+ //# debugId=492BCFB971F513C864756E2164756E21
3562
3573
  //# sourceMappingURL=reindex.js.map