Add indexing status guards for Subgraph API and Omnigraph API#2090
Conversation
…mnigraph API and Subgraph API availability.
…and Subgraph API routes.
…and Subgraph API views.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 9f5f0b5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…-api-omnigraph-api
📝 WalkthroughWalkthroughThis PR adds indexing-status-based prerequisites to prevent queries to Omnigraph and Subgraph APIs until backfill completes. The core validation utility checks for Completed or Following status, exported via SDK modules, enforced in API middleware returning 503 errors, and reflected in ENSAdmin UI status indicators. ChangesIndexing-status prerequisites and API gating
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR adds runtime indexing-status guards to both the Subgraph API and Omnigraph API handlers in
Confidence Score: 5/5Safe to merge — the changes are additive guards that can only make existing endpoints more restrictive, not less. All three layers (SDK, API handler, admin UI) implement the guard consistently. The middleware ordering in both handlers is correct: No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant Handler as ensapi Handler
participant ISM as indexingStatusMiddleware
participant Guard as Prerequisite Guard
participant Upstream as ENSIndexer / Cache
Client->>Handler: GET /subgraph or /api/omnigraph
Handler->>ISM: run indexingStatusMiddleware
ISM->>Upstream: read indexing status (SWR cache)
Upstream-->>ISM: "IndexingStatusSnapshot | Error"
ISM-->>Handler: c.var.indexingStatus set
Handler->>Guard: check config prerequisite
alt config not met
Guard-->>Client: 503 Service Unavailable (config reason)
end
Handler->>Guard: c.var.indexingStatus instanceof Error?
alt Error (never fetched)
Guard-->>Client: 503 Service Unavailable (snapshot unavailable)
end
Handler->>Guard: hasSubgraph/OmnigraphApiIndexingStatusSupport(omnichainStatus)
alt status not Completed or Following
Guard-->>Client: 503 Service Unavailable (backfill incomplete)
end
Guard-->>Handler: prerequisites met
Handler-->>Client: 200 OK (GraphQL response)
Reviews (3): Last reviewed commit: "Apply PR feedback" | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
This PR adds runtime gating so ENSApi’s Subgraph API and Omnigraph API only respond once omnichain indexing has reached an acceptable state (Completed/Following), and updates the SDK + ENSAdmin feature detection to reflect those new prerequisites.
Changes:
- Added indexing-status-based prerequisite helpers to
@ensnode/ensnode-sdkfor Subgraph and Omnigraph APIs. - Added 503 guards in ENSApi Subgraph + Omnigraph handlers when indexing status is unavailable or not in Completed/Following.
- Updated ENSAdmin feature detection to require both config support and indexing-status support.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ensnode-sdk/src/subgraph-api/prerequisites.ts | Adds hasSubgraphApiIndexingStatusSupport helper based on omnichain indexing status. |
| packages/ensnode-sdk/src/omnigraph-api/prerequisites.ts | Adds hasOmnigraphApiIndexingStatusSupport helper based on omnichain indexing status. |
| apps/ensapi/src/handlers/subgraph/subgraph-api.ts | Registers indexing status middleware up-front and enforces config + indexing-status prerequisites via 503. |
| apps/ensapi/src/handlers/api/omnigraph/omnigraph-api.ts | Registers indexing status middleware up-front and enforces config + indexing-status prerequisites via 503. |
| apps/ensadmin/src/hooks/active/use-ensadmin-features.tsx | Updates feature readiness logic to include indexing-status prerequisites for Subgraph/Omnigraph views. |
| .changeset/loose-pets-vanish.md | Changeset for ensapi release notes. |
| .changeset/four-cats-sink.md | Changeset for ensadmin release notes. |
| .changeset/calm-jobs-lay.md | Changeset for @ensnode/ensnode-sdk release notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…aph-api' of github.com:namehash/ensnode into feat/2086-indexing-status-guard-for-subgraph-api-omnigraph-api
| /** | ||
| * Check if provided OmnichainIndexingStatusId supports the Subgraph API. | ||
| */ | ||
| export function hasSubgraphApiIndexingStatusSupport( |
There was a problem hiding this comment.
imo DRY up this impl and have the reason message just say
`The connected ENSNode's Omnichain Indexing Status must be "${OmnichainIndexingStatusIds.Completed}" or "${OmnichainIndexingStatusIds.Following}". Current omnichain indexing status is "${indexingStatus}".`
lightwalker-eth
left a comment
There was a problem hiding this comment.
@tk-o Looks nice, thanks! 😄 Please take the lead to merge when ready 👍
…atus-guard-for-subgraph-api-omnigraph-api
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/ensapi/src/handlers/api/omnigraph/omnigraph-api.ts`:
- Around line 16-32: Replace the direct c.text(...) 503 returns with the shared
ENSApi errorResponse helper: where you check configPrerequisite (variable
configPrerequisite), the indexing status error (c.var.indexingStatus instanceof
Error) and the indexingStatusPrerequisite (result of
hasOmnigraphApiIndexingStatusSupport) call, call errorResponse(...) to produce
the 503 responses so the route uses the common response shape and behavior;
update imports to bring in errorResponse from the ENSApi error-response module
and pass the same message and status code currently used in each c.text(...)
call.
In `@apps/ensapi/src/handlers/subgraph/subgraph-api.ts`:
- Around line 35-52: Replace the direct c.text(...) early returns in
subgraph-api.ts with the shared errorResponse helper from
apps/ensapi/src/lib/handlers/error-response.ts so all three branches produce the
same ENSApi error shape/headers; specifically, when configPrerequisite.supported
is false, when c.var.indexingStatus is an Error, and when
indexingStatusPrerequisite.supported is false, call errorResponse(...) passing
the appropriate 503 status and a message (e.g., configPrerequisite.reason or the
indexing-status message) instead of returning c.text directly; update imports to
include errorResponse and ensure the status code is 503 in each call.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 100e8a30-0355-4990-9d22-554ac663f421
📒 Files selected for processing (9)
.changeset/calm-jobs-lay.md.changeset/four-cats-sink.md.changeset/loose-pets-vanish.mdapps/ensadmin/src/hooks/active/use-ensadmin-features.tsxapps/ensapi/src/handlers/api/omnigraph/omnigraph-api.tsapps/ensapi/src/handlers/subgraph/subgraph-api.tspackages/ensnode-sdk/src/ensnode/api/prerequisites.tspackages/ensnode-sdk/src/omnigraph-api/prerequisites.tspackages/ensnode-sdk/src/subgraph-api/prerequisites.ts
Lite PR
Tip: Review docs on the ENSNode PR process
Summary
ensapi, returning503 Service Unavailablewhen the omnichain indexing status is notCompletedorFollowing.hasSubgraphApiIndexingStatusSupport,hasOmnigraphApiIndexingStatusSupport) to@ensnode/ensnode-sdk.ensadminfrontend feature detection to reflect the new indexing-status prerequisites for both APIs.Why
Closes internal request to prevent clients from querying the Subgraph and Omnigraph APIs until backfill is complete. Previously, only static config-based prerequisites were checked; this change adds a dynamic runtime guard based on the actual indexing status snapshot.
Testing
Verified the new prerequisite functions return the expected
supported/not-supportedresults for eachOmnichainIndexingStatusIdsstate.Confirmed the
ensapihandlers return503with an appropriate reason when indexing status prerequisites are not met.Confirmed
ensadminfeature status transitions fromconnecting→not-ready(with reason) →supportedas indexing status progresses.Changesets included for
ensapi,ensadmin, andensnode-sdk.Notes for Reviewer (Optional)
indexingStatusMiddlewarewas already used in the Subgraph API handler but is now registered viacreateApp({ middlewares: [...] })for both APIs to ensurec.var.indexingStatusis available before the prerequisite checks run.Pre-Review Checklist (Blocking)