@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,
@@ -3398,5 +3409,5 @@ export {
3398
3409
  handleSubgraphReorg
3399
3410
  };
3400
3411
 
3401
- //# debugId=8717C174F5E08EB264756E2164756E21
3412
+ //# debugId=E41A1A11273A69DD64756E2164756E21
3402
3413
  //# sourceMappingURL=reorg.js.map