Conversation
This data model allows to capture the internal context object of the local Ponder app
This getter will allow the consumers of the local Ponder client to decide business logic based on the Ponder app context.
Skip ENSIndexer Pulic Config validation in dev mode.
🦋 Changeset detectedLatest commit: 2ad57bd The changes in this PR will be included in the next version bump. This PR includes changesets to release 19 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds Ponder app context types and deserialization; LocalPonderClient now stores PonderAppContext and exposes isInDevMode; EnsDbWriterWorker accepts LocalPonderClient and skips public-config compatibility validation in dev mode; tests, mocks, and initialization wiring updated accordingly. Changes
Sequence DiagramsequenceDiagram
participant App as Application Start
participant Deser as deserializePonderAppContext
participant Init as LocalPonderClient Init
participant LPC as LocalPonderClient
participant WorkerInit as EnsDbWriterWorker Init
participant Worker as EnsDbWriterWorker
participant Validator as Compatibility Validator
App->>Deser: read globalThis.PONDER_COMMON
Deser-->>Init: return PonderAppContext
Init->>LPC: construct(LocalPonderClient, ponderAppContext)
LPC-->>App: expose isInDevMode
App->>WorkerInit: construct EnsDbWriterWorker(..., localPonderClient)
WorkerInit-->>Worker: store localPonderClient
Worker->>Validator: getValidatedEnsIndexerPublicConfig(stored,inMemory)
Validator->>LPC: query isInDevMode
alt Dev mode (true)
Validator-->>Worker: skip compatibility check, return inMemory config
else Prod mode (false)
Validator->>Validator: validateEnsIndexerPublicConfigCompatibility(...)
Validator-->>Worker: return validated config or throw
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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 improves the ENSIndexer development experience by skipping the ENSDb Writer Worker's config compatibility validation when Ponder is running in dev mode ( Key changes:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Ponder as Ponder Runtime
participant LC as local-ponder-client.ts (module init)
participant DPAC as deserializePonderAppContext
participant LPC as LocalPonderClient
participant Worker as EnsDbWriterWorker
participant ENSDb as ENSDb
Ponder->>LC: inject globalThis.PONDER_COMMON
LC->>LC: guard: if (!PONDER_COMMON) throw
LC->>DPAC: deserializePonderAppContext(PONDER_COMMON)
DPAC-->>LC: PonderAppContext { command }
LC->>LPC: new LocalPonderClient(..., ponderAppContext)
Note over LPC: isInDevMode = command === "dev"
Worker->>Worker: run()
Worker->>Worker: getValidatedEnsIndexerPublicConfig()
Worker->>ENSDb: getEnsIndexerPublicConfig() [concurrent]
Worker->>Worker: publicConfigBuilder.getPublicConfig() [concurrent]
alt storedConfig exists AND NOT isInDevMode
Worker->>Worker: validateEnsIndexerPublicConfigCompatibility()
Note over Worker: throws on incompatibility
else isInDevMode OR no storedConfig
Worker->>Worker: skip validation (dev mode)
end
Worker->>ENSDb: upsertEnsDbVersion(...)
Worker->>ENSDb: upsertEnsIndexerPublicConfig(inMemoryConfig)
|
There was a problem hiding this comment.
Pull request overview
Adds a Ponder “app context” model (incl. command) to allow ENSIndexer to detect dev mode and skip ENSDb Writer Worker public-config compatibility validation during development.
Changes:
- Introduce
PonderAppContext/PonderAppCommandsplus Zod deserialization for Ponder’s injected runtime context. - Thread
PonderAppContextintoLocalPonderClientand exposeisInDevMode. - Skip
validateEnsIndexerPublicConfigCompatibility()inEnsDbWriterWorkerwhen running in dev mode; update mocks/tests and add changesets.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ponder-sdk/src/ponder-app-context.ts | Adds PonderAppContext + command constants/types. |
| packages/ponder-sdk/src/local-ponder-client.ts | Accepts app context and exposes isInDevMode. |
| packages/ponder-sdk/src/local-ponder-client.test.ts | Adds unit tests for isInDevMode + updates imports. |
| packages/ponder-sdk/src/local-ponder-client.mock.ts | Updates mock factory to provide ponderAppContext. |
| packages/ponder-sdk/src/indexing-metrics.ts | Moves PonderAppCommand typing to new context module. |
| packages/ponder-sdk/src/index.ts | Re-exports new context + deserializer modules. |
| packages/ponder-sdk/src/deserialize/ponder-app-context.ts | Adds Zod schemas and deserializePonderAppContext(). |
| packages/ponder-sdk/src/deserialize/indexing-metrics.ts | Reuses shared command schema for metrics deserialization. |
| packages/ponder-sdk/src/deserialize/indexing-metrics.mock.ts | Updates mock to import commands from new module. |
| apps/ensindexer/types/env.d.ts | Declares globalThis.PONDER_COMMON injected by Ponder. |
| apps/ensindexer/src/lib/local-ponder-client.ts | Builds ponderAppContext from PONDER_COMMON and passes to LocalPonderClient. |
| apps/ensindexer/src/lib/ensdb-writer-worker/singleton.ts | Injects localPonderClient into worker construction. |
| apps/ensindexer/src/lib/ensdb-writer-worker/ensdb-writer-worker.ts | Skips public-config compatibility validation when isInDevMode. |
| apps/ensindexer/src/lib/ensdb-writer-worker/ensdb-writer-worker.test.ts | Adds dev-mode test and refactors to use a worker factory mock. |
| apps/ensindexer/src/lib/ensdb-writer-worker/ensdb-writer-worker.mock.ts | Adds createMockEnsDbWriterWorker + createMockLocalPonderClient. |
| .changeset/old-seals-draw.md | Changeset for @ensnode/ponder-sdk (context model). |
| .changeset/better-bats-switch.md | Changeset for ensindexer (skip validation in dev mode). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/better-bats-switch.md:
- Line 5: Replace the typo "skiping" with "skipping" in the changeset text line
that mentions "ENSDb Writer Worker" so the sentence reads "skipping validation
step in ENSDb Writer Worker while in dev mode."; update only the word and keep
the rest of the line unchanged.
In `@apps/ensindexer/src/lib/ensdb-writer-worker/ensdb-writer-worker.test.ts`:
- Around line 84-86: The test is using persistent mocks via
vi.mocked(...).mockImplementation(...) which can leak between tests; change
those to one-shot mocks using
vi.mocked(validateEnsIndexerPublicConfigCompatibility).mockImplementationOnce(()
=> { throw new Error("incompatible"); }) (and similarly replace other
occurrences that call mockImplementation at the other spots) so each test gets
an isolated behavior and no cross-test leakage; update the three locations that
currently call mockImplementation to use mockImplementationOnce instead.
In `@packages/ponder-sdk/src/deserialize/ponder-app-context.ts`:
- Around line 33-38: The JSDoc for the Ponder App Context builder contains
redundant `@returns` tags that repeat the summary; remove the unnecessary `@returns`
lines from the JSDoc block that documents the function which builds the
unvalidated Ponder App Context (the comment referencing schemaPonderAppContext)
and also remove the redundant `@returns` in the other JSDoc block noted at lines
50-52 so the doc follows the repo guideline of not restating summaries.
- Around line 57-64: Replace the safeParse branch with a direct parse call: use
schemaRawPonderAppContext.transform(buildUnvalidatedPonderAppContext).pipe(schemaPonderAppContext).parse(unvalidatedRawPonderAppContext)
instead of .safeParse(...), remove the manual if (!validation.success) throw
block and use the returned parsed value (e.g., const validated = ...parse(...));
keep the same transform/pipe chain (schemaRawPonderAppContext,
buildUnvalidatedPonderAppContext, schemaPonderAppContext,
unvalidatedRawPonderAppContext) so validation fails fast by throwing rather than
manually checking validation.success.
🪄 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: 3a61495e-9046-4d90-b178-f11a3074de27
📒 Files selected for processing (17)
.changeset/better-bats-switch.md.changeset/old-seals-draw.mdapps/ensindexer/src/lib/ensdb-writer-worker/ensdb-writer-worker.mock.tsapps/ensindexer/src/lib/ensdb-writer-worker/ensdb-writer-worker.test.tsapps/ensindexer/src/lib/ensdb-writer-worker/ensdb-writer-worker.tsapps/ensindexer/src/lib/ensdb-writer-worker/singleton.tsapps/ensindexer/src/lib/local-ponder-client.tsapps/ensindexer/types/env.d.tspackages/ponder-sdk/src/deserialize/indexing-metrics.mock.tspackages/ponder-sdk/src/deserialize/indexing-metrics.tspackages/ponder-sdk/src/deserialize/ponder-app-context.tspackages/ponder-sdk/src/index.tspackages/ponder-sdk/src/indexing-metrics.tspackages/ponder-sdk/src/local-ponder-client.mock.tspackages/ponder-sdk/src/local-ponder-client.test.tspackages/ponder-sdk/src/local-ponder-client.tspackages/ponder-sdk/src/ponder-app-context.ts
…the internal context of a local Ponder app.
…step in ENSDb Writer Worker while in dev mode.
9811b95 to
326f9a4
Compare
|
@greptile review |
There was a problem hiding this comment.
♻️ Duplicate comments (3)
packages/ponder-sdk/src/deserialize/ponder-app-context.ts (2)
57-64: 🛠️ Refactor suggestion | 🟠 MajorUse
.parse()for this fail-fast non-API deserialization path.At Line [60], this path validates and then always throws on failure (Line [62]-Line [64]), so
safeParseadds unnecessary branching. Prefer direct.parse(...).♻️ Proposed change
-import { prettifyError, z } from "zod/v4"; +import { z } from "zod/v4"; @@ export function deserializePonderAppContext( unvalidatedRawPonderAppContext: Unvalidated<RawPonderAppContext> | undefined, ): PonderAppContext { - const validation = schemaRawPonderAppContext + return schemaRawPonderAppContext .transform(buildUnvalidatedPonderAppContext) .pipe(schemaPonderAppContext) - .safeParse(unvalidatedRawPonderAppContext); - - if (!validation.success) { - throw new Error(`Invalid raw Ponder App Context: ${prettifyError(validation.error)}`); - } - - return validation.data; + .parse(unvalidatedRawPonderAppContext); }#!/bin/bash # Verify this function currently uses safeParse in a fail-fast path. rg -n --type=ts 'deserializePonderAppContext|safeParse\(|\.parse\(' packages/ponder-sdk/src/deserialize/ponder-app-context.tsAs per coding guidelines "{apps,packages}//src//*.{ts,tsx}: Use
zod.parse(...)for fail-fast validation in non-API code; usezod.safeParse(...)when you need non-throwing branch for optional or fallback values".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/ponder-sdk/src/deserialize/ponder-app-context.ts` around lines 57 - 64, The code currently calls schemaRawPonderAppContext.transform(buildUnvalidatedPonderAppContext).pipe(schemaPonderAppContext).safeParse(unvalidatedRawPonderAppContext) and then throws on validation failure; replace this fail-fast path with a direct .parse(...) so it throws automatically: call schemaRawPonderAppContext.transform(buildUnvalidatedPonderAppContext).pipe(schemaPonderAppContext).parse(unvalidatedRawPonderAppContext) and remove the manual success check/throw (retain the prettifyError helper only if still needed elsewhere) so the function fails fast using Zod's built-in exception.
33-38: 🧹 Nitpick | 🔵 TrivialRemove redundant
@returnstags in these JSDoc blocks.The
@returnstext at Line [36]-Line [37] and Line [51] restates the summaries and should be removed to keep doc style consistent.As per coding guidelines "**/*.{ts,tsx}: Do not add JSDoc
@returnstags that merely restate the method summary; remove redundant comments during PR review".Also applies to: 47-52
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/ponder-sdk/src/deserialize/ponder-app-context.ts` around lines 33 - 38, Remove the redundant JSDoc `@returns` tags that merely repeat the summary: in the JSDoc for the buildUnvalidatedPonderAppContext block (the comment starting "Build unvalidated Ponder App Context" that references rawPonderAppContext and {`@link` schemaPonderAppContext}) and the other affected JSDoc block around lines 47–52; keep the summary and `@param` tags but delete the `@returns` lines so the documentation follows the project's guideline against restating the method summary.apps/ensindexer/src/lib/ensdb-writer-worker/ensdb-writer-worker.test.ts (1)
84-86:⚠️ Potential issue | 🟡 MinorUse one-shot implementations here to prevent cross-test mock leakage.
Line 84, Line 103, and Line 175 use persistent
mockImplementation(...); withvi.clearAllMocks()in cleanup, those implementations can bleed into later tests.♻️ Proposed fix
- vi.mocked(validateEnsIndexerPublicConfigCompatibility).mockImplementation(() => { + vi.mocked(validateEnsIndexerPublicConfigCompatibility).mockImplementationOnce(() => { throw new Error("incompatible"); }); - vi.mocked(validateEnsIndexerPublicConfigCompatibility).mockImplementation(() => { + vi.mocked(validateEnsIndexerPublicConfigCompatibility).mockImplementationOnce(() => { throw new Error("incompatible"); }); - vi.mocked(validateEnsIndexerPublicConfigCompatibility).mockImplementation(() => {}); + vi.mocked(validateEnsIndexerPublicConfigCompatibility).mockImplementationOnce(() => {});In Vitest, does vi.clearAllMocks() reset mock implementations set via mockImplementation(), or only clear call history?Also applies to: 103-105, 175-175
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/ensindexer/src/lib/ensdb-writer-worker/ensdb-writer-worker.test.ts` around lines 84 - 86, The tests set persistent mocks for validateEnsIndexerPublicConfigCompatibility using vi.mocked(...).mockImplementation(...), which can leak between tests; change those to one-shot mocks by using vi.mocked(validateEnsIndexerPublicConfigCompatibility).mockImplementationOnce(...) (or the Vitest equivalent) in each test that currently calls mockImplementation (the spots referencing validateEnsIndexerPublicConfigCompatibility around the failing tests) so each test receives a single-use implementation and does not affect subsequent tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@apps/ensindexer/src/lib/ensdb-writer-worker/ensdb-writer-worker.test.ts`:
- Around line 84-86: The tests set persistent mocks for
validateEnsIndexerPublicConfigCompatibility using
vi.mocked(...).mockImplementation(...), which can leak between tests; change
those to one-shot mocks by using
vi.mocked(validateEnsIndexerPublicConfigCompatibility).mockImplementationOnce(...)
(or the Vitest equivalent) in each test that currently calls mockImplementation
(the spots referencing validateEnsIndexerPublicConfigCompatibility around the
failing tests) so each test receives a single-use implementation and does not
affect subsequent tests.
In `@packages/ponder-sdk/src/deserialize/ponder-app-context.ts`:
- Around line 57-64: The code currently calls
schemaRawPonderAppContext.transform(buildUnvalidatedPonderAppContext).pipe(schemaPonderAppContext).safeParse(unvalidatedRawPonderAppContext)
and then throws on validation failure; replace this fail-fast path with a direct
.parse(...) so it throws automatically: call
schemaRawPonderAppContext.transform(buildUnvalidatedPonderAppContext).pipe(schemaPonderAppContext).parse(unvalidatedRawPonderAppContext)
and remove the manual success check/throw (retain the prettifyError helper only
if still needed elsewhere) so the function fails fast using Zod's built-in
exception.
- Around line 33-38: Remove the redundant JSDoc `@returns` tags that merely repeat
the summary: in the JSDoc for the buildUnvalidatedPonderAppContext block (the
comment starting "Build unvalidated Ponder App Context" that references
rawPonderAppContext and {`@link` schemaPonderAppContext}) and the other affected
JSDoc block around lines 47–52; keep the summary and `@param` tags but delete the
`@returns` lines so the documentation follows the project's guideline against
restating the method summary.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1eddb9b1-e009-4552-a28f-72f2b2b07bb1
📒 Files selected for processing (6)
.changeset/better-bats-switch.md.changeset/old-seals-draw.mdapps/ensindexer/src/lib/ensdb-writer-worker/ensdb-writer-worker.mock.tsapps/ensindexer/src/lib/ensdb-writer-worker/ensdb-writer-worker.test.tsapps/ensindexer/types/env.d.tspackages/ponder-sdk/src/deserialize/ponder-app-context.ts
326f9a4 to
64db38d
Compare
|
@greptile review |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 17 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/ensindexer/types/env.d.ts`:
- Around line 8-13: The file documents PONDER_COMMON but not ProcessEnv; make
comments consistent by adding a short JSDoc comment for the ProcessEnv
declaration (or alternatively remove the PONDER_COMMON block if you prefer
minimal docs). Locate the ProcessEnv type declaration and add a concise comment
describing it (e.g., "Node process env interface" or similar) to match the
existing PONDER_COMMON comment style, ensuring both declarations have equivalent
comment coverage and formatting.
🪄 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: 70618e04-0a09-4fc7-99b6-71a42fe3f23a
📒 Files selected for processing (2)
apps/ensindexer/src/lib/local-ponder-client.tsapps/ensindexer/types/env.d.ts
| /** | ||
| * Global variable injected by Ponder at runtime, | ||
| * containing internal context of the local Ponder app. | ||
| * | ||
| * @see https://github.com/ponder-sh/ponder/blob/6fcc15d4234e43862cb6e21c05f3c57f4c2f7464/packages/core/src/internal/common.ts#L7-L15 | ||
| */ |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Keep declaration comments consistent within this file.
Only PONDER_COMMON is documented while ProcessEnv is not; please normalize comment coverage for consistency (either add a short comment for ProcessEnv or simplify this block).
♻️ Minimal consistency fix (example)
declare global {
namespace NodeJS {
+ // Runtime environment variables validated by "@/config/environment".
interface ProcessEnv extends ENSIndexerEnvironment {}
}As per coding guidelines: "Maintain comment consistency within a file; address inconsistency if most declarations lack comments but one has them."
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /** | |
| * Global variable injected by Ponder at runtime, | |
| * containing internal context of the local Ponder app. | |
| * | |
| * @see https://github.com/ponder-sh/ponder/blob/6fcc15d4234e43862cb6e21c05f3c57f4c2f7464/packages/core/src/internal/common.ts#L7-L15 | |
| */ | |
| declare global { | |
| namespace NodeJS { | |
| // Runtime environment variables validated by "@/config/environment". | |
| interface ProcessEnv extends ENSIndexerEnvironment {} | |
| } | |
| /** | |
| * Global variable injected by Ponder at runtime, | |
| * containing internal context of the local Ponder app. | |
| * | |
| * `@see` https://github.com/ponder-sh/ponder/blob/6fcc15d4234e43862cb6e21c05f3c57f4c2f7464/packages/core/src/internal/common.ts#L7-L15 | |
| */ | |
| const PONDER_COMMON: PonderCommonType; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/ensindexer/types/env.d.ts` around lines 8 - 13, The file documents
PONDER_COMMON but not ProcessEnv; make comments consistent by adding a short
JSDoc comment for the ProcessEnv declaration (or alternatively remove the
PONDER_COMMON block if you prefer minimal docs). Locate the ProcessEnv type
declaration and add a concise comment describing it (e.g., "Node process env
interface" or similar) to match the existing PONDER_COMMON comment style,
ensuring both declarations have equivalent comment coverage and formatting.
64db38d to
6a85c84
Compare
|
@greptile review |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 17 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // if the stored one is available. | ||
| // The validation is skipped if the local Ponder app is running in dev mode. | ||
| // This is to improve the development experience during ENSIndexer | ||
| // development, by allowing to override the stored config in ENSDb with | ||
| // the current in-memory config, without having to keep them compatible. |
There was a problem hiding this comment.
The method-level docs above say compatibility validation runs whenever a stored config exists, but the implementation now skips validation in dev mode. Please update the docstring/@throws description to reflect the new behavior (i.e., validation is conditional on both storedConfig and not being in dev mode).
| // if the stored one is available. | |
| // The validation is skipped if the local Ponder app is running in dev mode. | |
| // This is to improve the development experience during ENSIndexer | |
| // development, by allowing to override the stored config in ENSDb with | |
| // the current in-memory config, without having to keep them compatible. | |
| // if the stored one is available and the local Ponder app is not running | |
| // in dev mode. | |
| // The validation is intentionally skipped in dev mode to improve the | |
| // development experience during ENSIndexer development, by allowing | |
| // overriding the stored config in ENSDb with the current in-memory config | |
| // without having to keep them compatible. |
There was a problem hiding this comment.
Thanks, will update the docs.
6a85c84 to
2ad57bd
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (3)
apps/ensindexer/types/env.d.ts (1)
8-11: 🧹 Nitpick | 🔵 TrivialKeep the declaration comments consistent within this file.
Only
PONDER_COMMONis documented right now. Please either add a matching short comment forNodeJS.ProcessEnvor drop this block.🧹 Minimal consistency fix
declare global { namespace NodeJS { + /** Runtime environment variables validated by "@/config/environment". */ interface ProcessEnv extends ENSIndexerEnvironment {} } /** * The "raw" context of the local Ponder app.As per coding guidelines "Maintain comment consistency within a file; address inconsistency if most declarations lack comments but one has them".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/ensindexer/types/env.d.ts` around lines 8 - 11, The file has an inconsistent doc comment for PONDER_COMMON while NodeJS.ProcessEnv is undocumented; either add a matching short comment above the NodeJS.ProcessEnv declaration or remove the comment block for PONDER_COMMON so both declarations match; locate the declarations for PONDER_COMMON and NodeJS.ProcessEnv in the env.d.ts types and update the comments accordingly to keep them consistent.packages/ponder-sdk/src/deserialize/ponder-app-context.ts (2)
63-75: 🛠️ Refactor suggestion | 🟠 MajorUse
parse()for this fail-fast deserializer.This path always throws on invalid input, so
safeParse()only adds manual branching that the caller never uses.♻️ Proposed change
-import { prettifyError, z } from "zod/v4"; +import { z } from "zod/v4"; @@ export function deserializePonderAppContext( unvalidatedRawPonderAppContext: Unvalidated<RawPonderAppContext>, ): PonderAppContext { - const validation = schemaRawPonderAppContext + return schemaRawPonderAppContext .transform(buildUnvalidatedPonderAppContext) .pipe(schemaPonderAppContext) - .safeParse(unvalidatedRawPonderAppContext); - - if (!validation.success) { - throw new Error(`Invalid raw Ponder App Context: ${prettifyError(validation.error)}`); - } - - return validation.data; + .parse(unvalidatedRawPonderAppContext); }Run this to confirm the function is using a fail-fast path and compare it with sibling deserializers:
#!/bin/bash sed -n '63,76p' packages/ponder-sdk/src/deserialize/ponder-app-context.ts rg -n --type=ts 'safeParse\(|\.parse\(' packages/ponder-sdk/src/deserializeAs per coding guidelines "Use
zod.parse(...)for fail-fast validation in non-API code; usezod.safeParse(...)when you need non-throwing branch for optional or fallback values".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/ponder-sdk/src/deserialize/ponder-app-context.ts` around lines 63 - 75, Replace the non-fail-fast safeParse branch in deserializePonderAppContext with a direct fail-fast parse: call the transformed schema (schemaRawPonderAppContext.transform(buildUnvalidatedPonderAppContext).pipe(schemaPonderAppContext)) using parse(...) instead of safeParse(...), remove the manual if (!validation.success) branching and the prettified error handling, and let parse() throw on invalid input so the function returns validation.data directly; reference the symbols deserializePonderAppContext, schemaRawPonderAppContext, buildUnvalidatedPonderAppContext, and schemaPonderAppContext to locate the change.
41-47: 🧹 Nitpick | 🔵 TrivialDrop the redundant
@returnstags.Both tags restate the summaries and add noise to the new docs.
As per coding guidelines "Do not add JSDoc
@returnstags that merely restate the method summary; remove redundant comments during PR review".Also applies to: 56-61
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/ponder-sdk/src/deserialize/ponder-app-context.ts` around lines 41 - 47, Remove the redundant JSDoc `@returns` tags that merely restate the summary in the Ponder App Context builders: delete the duplicate `@returns` entries in the JSDoc for the "Build unvalidated Ponder App Context" comment block and the similar block at lines 56-61 so only the summary and useful param/throws tags remain; locate the JSDoc around the function that mentions schemaPonderAppContext (the build/unvalidated context function) and remove the extra `@returns` annotations.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/ensindexer/src/lib/ensdb-writer-worker/ensdb-writer-worker.ts`:
- Around line 147-156: The dev-mode bypass that skips config compatibility
validation in the function that loads/validates ENSDb config (look for the logic
around the dev-mode check in ensure/validate or the method that fetches stored
and in-memory configs) must be gated to avoid accidental overwrites of shared
ENSDb: require an explicit opt-in environment variable (e.g.,
ALLOW_DEV_MODE_CONFIG_OVERRIDE=true) before skipping validation, and
additionally verify the DATABASE_URL refers to a local/disposable target (reject
if it looks like a production/staging host) unless the opt-in is present; update
the conditional that currently short-circuits validation in dev mode to check
both the env opt-in and a local-DB pattern, and throw an error when dev-mode
bypass is requested without the opt-in or when DATABASE_URL is non-local so the
stored config cannot be silently overwritten.
---
Duplicate comments:
In `@apps/ensindexer/types/env.d.ts`:
- Around line 8-11: The file has an inconsistent doc comment for PONDER_COMMON
while NodeJS.ProcessEnv is undocumented; either add a matching short comment
above the NodeJS.ProcessEnv declaration or remove the comment block for
PONDER_COMMON so both declarations match; locate the declarations for
PONDER_COMMON and NodeJS.ProcessEnv in the env.d.ts types and update the
comments accordingly to keep them consistent.
In `@packages/ponder-sdk/src/deserialize/ponder-app-context.ts`:
- Around line 63-75: Replace the non-fail-fast safeParse branch in
deserializePonderAppContext with a direct fail-fast parse: call the transformed
schema
(schemaRawPonderAppContext.transform(buildUnvalidatedPonderAppContext).pipe(schemaPonderAppContext))
using parse(...) instead of safeParse(...), remove the manual if
(!validation.success) branching and the prettified error handling, and let
parse() throw on invalid input so the function returns validation.data directly;
reference the symbols deserializePonderAppContext, schemaRawPonderAppContext,
buildUnvalidatedPonderAppContext, and schemaPonderAppContext to locate the
change.
- Around line 41-47: Remove the redundant JSDoc `@returns` tags that merely
restate the summary in the Ponder App Context builders: delete the duplicate
`@returns` entries in the JSDoc for the "Build unvalidated Ponder App Context"
comment block and the similar block at lines 56-61 so only the summary and
useful param/throws tags remain; locate the JSDoc around the function that
mentions schemaPonderAppContext (the build/unvalidated context function) and
remove the extra `@returns` annotations.
🪄 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: cb52e173-d57d-4e82-8fd4-d39aca3a0268
📒 Files selected for processing (5)
apps/ensindexer/src/lib/ensdb-writer-worker/ensdb-writer-worker.tsapps/ensindexer/src/lib/local-ponder-client.tsapps/ensindexer/types/env.d.tspackages/ponder-sdk/src/deserialize/indexing-metrics.tspackages/ponder-sdk/src/deserialize/ponder-app-context.ts
Lite PR
Tip: Review docs on the ENSNode PR process
Summary
PonderAppContextdata model to capture relevant context from the local Ponder appglobalThis.PONDER_COMMONconst, that is injected by Ponder into ENSIndexer runtime.packages/ponder-sdk/src/deserialize/ponder-app-context.tsLocalPonderClientnow receives thePonderAppContextobject with constructor paramsLocalPonderClientdefinesisInDevMode(): booleangetter to enable ENSIndexer app modules to include conditional logic based on the local Ponder app mode.packages/ponder-sdk/src/local-ponder-client.tsEnsDbWriterWorkernow useslocalPonderClientinstance to skip the ENSIndexer Public Config validation when the local Ponder app is in the dev mode.apps/ensindexer/src/lib/ensdb-writer-worker/ensdb-writer-worker.tsWhy
Problem
During ENSIndexer development, developers frequently change configuration (e.g., active plugins, ENS Namespace) between runs. The ENSDb Writer Worker validates that the in-memory config matches the previously stored config in ENSDb. This caused crashes on subsequent runs because the stored config from the previous run was incompatible with the new in-memory config, forcing developers to manually clear the database between runs.
Solution
Skip config compatibility validation when Ponder is running in dev mode, allowing developers to iterate without database resets.
Testing
Notes for Reviewer (Optional)
Pre-Review Checklist (Blocking)