Skip to content

Add indexing status guards for Subgraph API and Omnigraph API#2090

Merged
tk-o merged 11 commits into
mainfrom
feat/2086-indexing-status-guard-for-subgraph-api-omnigraph-api
May 12, 2026
Merged

Add indexing status guards for Subgraph API and Omnigraph API#2090
tk-o merged 11 commits into
mainfrom
feat/2086-indexing-status-guard-for-subgraph-api-omnigraph-api

Conversation

@tk-o
Copy link
Copy Markdown
Member

@tk-o tk-o commented May 11, 2026

Lite PR

Tip: Review docs on the ENSNode PR process

Summary

  • Added indexing-status-based guards to the Subgraph API and Omnigraph API backend routes in ensapi, returning 503 Service Unavailable when the omnichain indexing status is not Completed or Following.
  • Added corresponding indexing-status prerequisite checks (hasSubgraphApiIndexingStatusSupport, hasOmnigraphApiIndexingStatusSupport) to @ensnode/ensnode-sdk.
  • Updated ensadmin frontend 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-supported results for each OmnichainIndexingStatusIds state.

  • Confirmed the ensapi handlers return 503 with an appropriate reason when indexing status prerequisites are not met.

    •  ❯ curl http://localhost:4334/api/omnigraph
       Service Unavailable: The connected ENSNode's Omnichain Indexing Status must be "omnichain-completed" or "omnichain-following" for the Omnigraph API to be available. Current omnichain indexing status is "omnichain-backfill".
      
        ❯ curl http://localhost:4334/subgraph
       Service Unavailable: The connected ENSNode's Omnichain Indexing Status must be "omnichain-completed" or "omnichain-following" for the Subgraph API to be available. Current omnichain indexing status is "omnichain-backfill".
      
  • Confirmed ensadmin feature status transitions from connectingnot-ready (with reason) → supported as indexing status progresses.

    • image
    • image
  • Changesets included for ensapi, ensadmin, and ensnode-sdk.


Notes for Reviewer (Optional)


Pre-Review Checklist (Blocking)

  • This PR does not introduce significant changes and is low-risk to review quickly.
  • Relevant changesets are included (or are not required)

Copilot AI review requested due to automatic review settings May 11, 2026 17:33
@tk-o tk-o requested a review from a team as a code owner May 11, 2026 17:33
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
admin.ensnode.io Ready Ready Preview, Comment May 12, 2026 8:25am
enskit-react-example.ensnode.io Ready Ready Preview, Comment May 12, 2026 8:25am
ensnode.io Ready Ready Preview, Comment May 12, 2026 8:25am
ensrainbow.io Ready Ready Preview, Comment May 12, 2026 8:25am

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 11, 2026

🦋 Changeset detected

Latest commit: 9f5f0b5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@ensnode/ensnode-sdk Major
ensadmin Major
ensapi Major
ensindexer Major
ensrainbow Major
fallback-ensapi Major
@namehash/ens-referrals Major
@ensnode/ensdb-sdk Major
@ensnode/ensnode-react Major
@ensnode/ensrainbow-sdk Major
@ensnode/integration-test-env Major
@namehash/namehash-ui Major
@docs/ensnode Major
@docs/ensrainbow Major
enssdk Major
enscli Major
enskit Major
ensskills Major
@ensnode/datasources Major
@ensnode/ponder-sdk Major
@ensnode/ponder-subgraph Major
@ensnode/shared-configs Major
@ensnode/ensindexer-perf-testing Major
@ensnode/enskit-react-example Patch

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 11, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This 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.

Changes

Indexing-status prerequisites and API gating

Layer / File(s) Summary
Core backfill prerequisite utility
packages/ensnode-sdk/src/ensnode/api/prerequisites.ts
hasBackfillCompleted validates omnichain indexing status against Completed or Following, returning a PrerequisiteResult with a formatted failure reason when not satisfied.
SDK-level prerequisite exports
packages/ensnode-sdk/src/omnigraph-api/prerequisites.ts, packages/ensnode-sdk/src/subgraph-api/prerequisites.ts
Omnigraph and Subgraph API prerequisite modules import hasBackfillCompleted and export hasOmnigraphApiIndexingStatusSupport and hasSubgraphApiIndexingStatusSupport respectively, delegating status checks to the core utility.
API middleware guards
apps/ensapi/src/handlers/api/omnigraph/omnigraph-api.ts, apps/ensapi/src/handlers/subgraph/subgraph-api.ts
Both API handlers register indexingStatusMiddleware via createApp({ middlewares: [...] }) and implement gating middleware that returns HTTP 503 when indexing-status prerequisites are not met, when the status snapshot is an Error, or when config prerequisites fail.
ENSAdmin feature status evaluation
apps/ensadmin/src/hooks/active/use-ensadmin-features.tsx
Features hook updated to check both config and indexing-status prerequisites for subgraph and omnigraph features, returning not-ready status with reason when indexing-status prerequisites are unsatisfied.
Release documentation
.changeset/calm-jobs-lay.md, .changeset/four-cats-sink.md, .changeset/loose-pets-vanish.md
Three changesets documenting minor version bumps for @ensnode/ensnode-sdk, ensadmin, and ensapi with release notes about indexing-status-based availability checks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • namehash/ensnode#1613: Adds Indexing Status Builder that produces OmnichainIndexingStatusSnapshot data; this PR consumes that snapshot through the prerequisite helpers and API guards.

Suggested labels

javascript

Poem

🐰 A rabbit hops through indexing states,
No query served 'til backfill waits,
With prerequisites complete and true,
The Omnigraph and Subgraph shine anew! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding indexing status guards for Subgraph API and Omnigraph API, which is the primary objective of the PR.
Description check ✅ Passed The PR description follows the template with all required sections: Summary, Why, Testing, Notes for Reviewer, and Pre-Review Checklist. Testing details include curl responses, screenshots, and feature status transitions.
Linked Issues check ✅ Passed The PR fully addresses #2086 objectives: backend returns 503 during backfill [ensapi handlers], frontend shows error messages [ensadmin hook], and prerequisite checks [SDK functions] prevent access until indexing reaches required status.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing indexing-status guards: middleware registration, prerequisite functions, API handlers, feature detection, and changesets. No extraneous modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/2086-indexing-status-guard-for-subgraph-api-omnigraph-api

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 11, 2026

Greptile Summary

This PR adds runtime indexing-status guards to both the Subgraph API and Omnigraph API handlers in ensapi, returning 503 Service Unavailable when the omnichain indexing status is not Completed or Following. It also adds corresponding SDK prerequisite functions and updates ensadmin feature detection to surface a not-ready state during backfill.

  • ensnode-sdk: Introduces a private hasBackfillCompleted helper in src/ensnode/api/prerequisites.ts and exposes hasSubgraphApiIndexingStatusSupport / hasOmnigraphApiIndexingStatusSupport as thin wrappers; both are exported from the public SDK surface.
  • ensapi: Both API handlers now receive indexingStatusMiddleware via createApp({ middlewares: [...] }), ensuring c.var.indexingStatus is populated before the prerequisite check runs; the guard returns 503 on an Error value or an unsupported indexing status.
  • ensadmin: The subgraph and omnigraph feature-status memos now chain a config check followed by the new indexing-status check, transitioning to not-ready (with reason) until backfill completes.

Confidence Score: 5/5

Safe 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: indexingStatusMiddleware is registered first via createApp, so c.var.indexingStatus is always populated before the prerequisite check runs. The instanceof Error branch handles the case where the cache was never successfully populated. No existing behaviour is regressed; at worst a client receives a 503 it wouldn't have seen before, which is the intended outcome.

No files require special attention.

Important Files Changed

Filename Overview
packages/ensnode-sdk/src/ensnode/api/prerequisites.ts New shared helper hasBackfillCompleted checking if omnichain status is Completed or Following; intentionally not re-exported from the public SDK surface.
apps/ensapi/src/handlers/subgraph/subgraph-api.ts Moves indexingStatusMiddleware to createApp options and adds indexing-status-based 503 guard; ordering is correct.
apps/ensapi/src/handlers/api/omnigraph/omnigraph-api.ts Adds indexingStatusMiddleware via createApp and an indexing-status-based 503 guard; consistent with the updated subgraph handler.
apps/ensadmin/src/hooks/active/use-ensadmin-features.tsx Extends subgraph and omnigraph feature checks with the new indexing-status prerequisite, returning not-ready when backfill is incomplete.

Sequence Diagram

sequenceDiagram
    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)
Loading

Reviews (3): Last reviewed commit: "Apply PR feedback" | Re-trigger Greptile

Comment thread packages/ensnode-sdk/src/subgraph-api/prerequisites.ts
Comment thread packages/ensnode-sdk/src/subgraph-api/prerequisites.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-sdk for 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.

Comment thread apps/ensapi/src/handlers/subgraph/subgraph-api.ts
Comment thread apps/ensapi/src/handlers/api/omnigraph/omnigraph-api.ts
Comment thread packages/ensnode-sdk/src/subgraph-api/prerequisites.ts Outdated
Comment thread packages/ensnode-sdk/src/omnigraph-api/prerequisites.ts Outdated
tk-o added 2 commits May 11, 2026 19:45
…aph-api' of github.com:namehash/ensnode into feat/2086-indexing-status-guard-for-subgraph-api-omnigraph-api
Copy link
Copy Markdown
Member

@shrugs shrugs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with minor nit

/**
* Check if provided OmnichainIndexingStatusId supports the Subgraph API.
*/
export function hasSubgraphApiIndexingStatusSupport(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}".`

Copy link
Copy Markdown
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tk-o Looks nice, thanks! 😄 Please take the lead to merge when ready 👍

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0b0f4ed and cc89001.

📒 Files selected for processing (9)
  • .changeset/calm-jobs-lay.md
  • .changeset/four-cats-sink.md
  • .changeset/loose-pets-vanish.md
  • apps/ensadmin/src/hooks/active/use-ensadmin-features.tsx
  • apps/ensapi/src/handlers/api/omnigraph/omnigraph-api.ts
  • apps/ensapi/src/handlers/subgraph/subgraph-api.ts
  • packages/ensnode-sdk/src/ensnode/api/prerequisites.ts
  • packages/ensnode-sdk/src/omnigraph-api/prerequisites.ts
  • packages/ensnode-sdk/src/subgraph-api/prerequisites.ts

Comment thread apps/ensapi/src/handlers/api/omnigraph/omnigraph-api.ts
Comment thread apps/ensapi/src/handlers/subgraph/subgraph-api.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Comment thread apps/ensapi/src/handlers/subgraph/subgraph-api.ts
Comment thread apps/ensapi/src/handlers/api/omnigraph/omnigraph-api.ts
Comment thread packages/ensnode-sdk/src/ensnode/api/prerequisites.ts
@tk-o tk-o merged commit 3132a77 into main May 12, 2026
25 checks passed
@tk-o tk-o deleted the feat/2086-indexing-status-guard-for-subgraph-api-omnigraph-api branch May 12, 2026 08:35
@github-actions github-actions Bot mentioned this pull request May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow using Subgraph API and Omnigraph API only after backfill was completed

4 participants