Skip to content

Fix wildcard handlerWithLoader regression - #673

Merged
DZakh merged 2 commits into
mainfrom
dz/fix-handler-with-loader-regression
Aug 11, 2025
Merged

DZakh merged 2 commits into
mainfrom
dz/fix-handler-with-loader-regression

Conversation

@DZakh

@DZakh DZakh commented Aug 8, 2025

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added support for new event handlers with filtering and wildcard capabilities.
    • Expanded configuration to include two additional events for event filtering tests.
  • Bug Fixes

    • Corrected optional event filter handling in event registration for improved consistency.
  • Tests

    • Standardized event processing in tests for better consistency.
    • Added tests verifying event filter behavior and wildcard handler functionality.

@coderabbitai

coderabbitai Bot commented Aug 8, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This update corrects a typo and changes event filter handling to use an explicit option type in the event handler template. It adds two new event entries and corresponding handlerWithLoader implementations—one filtered and one wildcard—to the test code. The test suite is updated to use batch event processing and includes new tests for filter behavior and wildcard handler regression.

Changes

Cohort / File(s) Change Summary
Event Handler Template Logic
codegenerator/cli/templates/dynamic/codegen/src/Types.res.hbs
Fixed a typo in a variable name (loaderRetrun to loaderReturn) and changed eventFilters in eventOptions to be wrapped as an option type (?eventConfig.eventFilters) in MakeRegister.handlerWithLoader.
Event Configuration
scenarios/test_codegen/config.yaml
Added two new event entries: "FilterTestEvent(address indexed addr)" and "WildcardHandlerWithLoader()" under the "EventFiltersTest" contract configuration.
Event Handler Implementations
scenarios/test_codegen/src/EventHandlers.ts
Added two new handlerWithLoader event handlers in the EventFiltersTest namespace: one filtered handler that throws on a specific address, and one wildcard handler with no-op behavior.
Event Handler Tests
scenarios/test_codegen/test/EventHandler_test.ts
Replaced all calls to Gravatar.FactoryEvent.processEvent with mockDb.processEvents for batch processing. Added tests verifying that event filters are ignored by the test framework and that the wildcard loader handler does not regress. No other test logic changes.

Sequence Diagram(s)

sequenceDiagram
    participant Event as Event
    participant Loader as Loader
    participant Handler as Handler
    participant DB as mockDb

    Note over Event,Loader: FilterTestEvent.handlerWithLoader flow
    Event->>Loader: Call loader(event)
    Loader-->>Handler: Return loader result (undefined)
    Handler->>Handler: If event.addr == "0x000" throw error
    Handler-->>DB: Handler completes or throws

    Note over Event,Loader: WildcardHandlerWithLoader flow
    Event->>Loader: Call loader(event)
    Loader-->>Handler: Return loader result (undefined)
    Handler-->>DB: Handler completes (no-op)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Poem

Two new events hop into the code,
With loaders and filters, in testing they're showed.
Wildcards and errors, all handled with care,
The template now wraps options in air.
With each review step, the bunnies delight—
For code that is tidy, and tests that are right!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa5e4d4 and f96f779.

📒 Files selected for processing (4)
  • codegenerator/cli/templates/dynamic/codegen/src/Types.res.hbs (2 hunks)
  • scenarios/test_codegen/config.yaml (1 hunks)
  • scenarios/test_codegen/src/EventHandlers.ts (1 hunks)
  • scenarios/test_codegen/test/EventHandler_test.ts (14 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • scenarios/test_codegen/config.yaml
  • codegenerator/cli/templates/dynamic/codegen/src/Types.res.hbs
  • scenarios/test_codegen/src/EventHandlers.ts
  • scenarios/test_codegen/test/EventHandler_test.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_and_test
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dz/fix-handler-with-loader-regression

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
codegenerator/cli/templates/dynamic/codegen/src/Types.res.hbs (1)

364-366: Nit: fix variable typo loaderRetrun → loaderReturn

Minor typo in local variable name; aligns better with property name and avoids confusion.

-          promise->Promise.then(loaderRetrun => {
-            (args->Obj.magic)["loaderReturn"] = loaderRetrun
+          promise->Promise.then(loaderReturn => {
+            (args->Obj.magic)["loaderReturn"] = loaderReturn
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2245985 and aa5e4d4.

📒 Files selected for processing (4)
  • codegenerator/cli/templates/dynamic/codegen/src/Types.res.hbs (1 hunks)
  • scenarios/test_codegen/config.yaml (1 hunks)
  • scenarios/test_codegen/src/EventHandlers.ts (1 hunks)
  • scenarios/test_codegen/test/EventHandler_test.ts (13 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
scenarios/test_codegen/**/{schema.graphql,config.yaml}

📄 CodeRabbit Inference Engine (scenarios/test_codegen/.cursor/rules/hyperindex.mdc)

After any change to schema.graphql or config.yaml, run pnpm codegen

Files:

  • scenarios/test_codegen/config.yaml
scenarios/test_codegen/**/*.{ts,yaml}

📄 CodeRabbit Inference Engine (scenarios/test_codegen/.cursor/rules/hyperindex.mdc)

When matching addresses in configuration objects, ensure case consistency by using lowercase keys in config objects to match address.toLowerCase() lookups

Files:

  • scenarios/test_codegen/config.yaml
  • scenarios/test_codegen/src/EventHandlers.ts
  • scenarios/test_codegen/test/EventHandler_test.ts
scenarios/test_codegen/**/*.yaml

📄 CodeRabbit Inference Engine (scenarios/test_codegen/.cursor/rules/hyperindex.mdc)

scenarios/test_codegen/**/*.yaml: If using event.transaction.hash or other transaction-level data, explicitly define it under field_selection in config.yaml
Use the provided schema file (# yaml-language-server: $schema=./node_modules/envio/evm.schema.json) to validate config.yaml
When creating token/config files, address keys must be lowercase for consistent matching
When creating token/config files, all required token metadata (name, symbol, decimals) must be included

Files:

  • scenarios/test_codegen/config.yaml
codegenerator/cli/templates/{dynamic/**/*.hbs,static/**}

📄 CodeRabbit Inference Engine (.cursor/rules/navigation.mdc)

Templates live under codegenerator/cli/templates: dynamic/ for Handlebars (.hbs), static/ for raw Rescript files copied verbatim.

Files:

  • codegenerator/cli/templates/dynamic/codegen/src/Types.res.hbs
scenarios/test_codegen/**/*.ts

📄 CodeRabbit Inference Engine (scenarios/test_codegen/.cursor/rules/hyperindex.mdc)

scenarios/test_codegen/**/*.ts: After any change to TypeScript files, run pnpm tsc --noEmit to ensure it compiles successfully
When updating existing entities, always use the spread operator because returned objects are read-only and immutable
Always cast timestamps to BigInt: BigInt(event.block.timestamp); never use raw timestamps from events
Use string | undefined for optional string fields, not string | null
Always normalize amounts when adding tokens with different decimal places; never add raw amounts from different tokens without normalization
When creating new entities, ensure all required fields are present in the entity object
When creating new entities, ensure relationships use entity_id fields, not direct objects
When creating new entities, ensure optional fields use undefined not null
When creating token/config files, helper functions must handle case-insensitive lookups
After code changes, run pnpm tsc --noEmit to catch type errors
Check for missing required fields in entity types after code changes
Verify relationship field names match generated types after code changes

Files:

  • scenarios/test_codegen/src/EventHandlers.ts
  • scenarios/test_codegen/test/EventHandler_test.ts
scenarios/test_codegen/**/*.{ts,graphql}

📄 CodeRabbit Inference Engine (scenarios/test_codegen/.cursor/rules/hyperindex.mdc)

scenarios/test_codegen/**/*.{ts,graphql}: In Envio, use entity_id fields (e.g., token_id: string) instead of direct object references for relationships
The generated types expect token_id not token for relationships

Files:

  • scenarios/test_codegen/src/EventHandlers.ts
  • scenarios/test_codegen/test/EventHandler_test.ts
🧠 Learnings (22)
📚 Learning: 2025-08-04T07:36:16.824Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:36:16.824Z
Learning: Applies to scenarios/test_codegen/**/*.yaml : If using event.transaction.hash or other transaction-level data, explicitly define it under field_selection in config.yaml

Applied to files:

  • scenarios/test_codegen/config.yaml
📚 Learning: 2025-08-04T07:36:16.824Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:36:16.824Z
Learning: Applies to scenarios/test_codegen/**/*.graphql : Do not add the entity decorator to GraphQL schema types

Applied to files:

  • scenarios/test_codegen/config.yaml
📚 Learning: 2025-08-04T07:36:16.824Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:36:16.824Z
Learning: Applies to scenarios/test_codegen/**/*.yaml : When creating token/config files, all required token metadata (name, symbol, decimals) must be included

Applied to files:

  • scenarios/test_codegen/config.yaml
📚 Learning: 2025-08-04T07:36:16.824Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:36:16.824Z
Learning: Applies to scenarios/test_codegen/**/*.ts : Check for missing required fields in entity types after code changes

Applied to files:

  • scenarios/test_codegen/config.yaml
  • codegenerator/cli/templates/dynamic/codegen/src/Types.res.hbs
  • scenarios/test_codegen/src/EventHandlers.ts
  • scenarios/test_codegen/test/EventHandler_test.ts
📚 Learning: 2025-08-04T07:36:16.824Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:36:16.824Z
Learning: Applies to scenarios/test_codegen/**/*.graphql : Use `entity_id` fields for relationships instead of entity arrays in GraphQL schemas

Applied to files:

  • scenarios/test_codegen/config.yaml
📚 Learning: 2025-08-04T07:36:16.824Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:36:16.824Z
Learning: Applies to scenarios/test_codegen/**/*.yaml : When creating token/config files, address keys must be lowercase for consistent matching

Applied to files:

  • scenarios/test_codegen/config.yaml
📚 Learning: 2025-08-04T07:36:16.824Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:36:16.824Z
Learning: Applies to scenarios/test_codegen/**/*.{ts,yaml} : When matching addresses in configuration objects, ensure case consistency by using lowercase keys in config objects to match `address.toLowerCase()` lookups

Applied to files:

  • scenarios/test_codegen/config.yaml
📚 Learning: 2025-08-04T07:35:49.055Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:35:49.055Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : When creating new entities, ensure all required fields are present, timestamps are cast to BigInt, relationships use `entity_id` fields, updates use spread operator, and optional fields use `undefined` not `null`

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Types.res.hbs
  • scenarios/test_codegen/test/EventHandler_test.ts
📚 Learning: 2025-08-04T07:35:20.300Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-08-04T07:35:20.300Z
Learning: Applies to codegenerator/cli/templates/{dynamic/**/*.hbs,static/**} : Templates live under codegenerator/cli/templates: dynamic/ for Handlebars (.hbs), static/ for raw Rescript files copied verbatim.

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Types.res.hbs
📚 Learning: 2025-08-04T07:35:49.055Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:35:49.055Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : When updating existing entities, always use the spread operator because returned objects are read-only and immutable

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Types.res.hbs
📚 Learning: 2025-08-04T07:35:49.055Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:35:49.055Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Use `string | undefined` for optional string fields, not `string | null`

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Types.res.hbs
📚 Learning: 2025-08-04T07:36:16.824Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:36:16.824Z
Learning: Applies to scenarios/test_codegen/**/*.ts : When creating new entities, ensure optional fields use `undefined` not `null`

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Types.res.hbs
  • scenarios/test_codegen/src/EventHandlers.ts
  • scenarios/test_codegen/test/EventHandler_test.ts
📚 Learning: 2025-08-04T07:36:16.824Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:36:16.824Z
Learning: Applies to scenarios/test_codegen/**/*.ts : Use `string | undefined` for optional string fields, not `string | null`

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Types.res.hbs
  • scenarios/test_codegen/src/EventHandlers.ts
📚 Learning: 2025-08-04T07:35:49.055Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:35:49.055Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Always cast timestamps to BigInt: `BigInt(event.block.timestamp)`; never use raw timestamps from events

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Types.res.hbs
📚 Learning: 2025-08-04T07:35:49.055Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:35:49.055Z
Learning: Applies to codegenerator/cli/templates/static/shared/{schema.graphql,**/*.ts} : After schema changes, run `pnpm codegen`; after TypeScript changes, run `pnpm tsc --noEmit` to catch type errors; check for missing required fields in entity types and verify relationship field names match generated types

Applied to files:

  • codegenerator/cli/templates/dynamic/codegen/src/Types.res.hbs
📚 Learning: 2025-08-04T07:36:16.824Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:36:16.824Z
Learning: Applies to scenarios/test_codegen/**/*.ts : Always cast timestamps to BigInt: `BigInt(event.block.timestamp)`; never use raw timestamps from events

Applied to files:

  • scenarios/test_codegen/src/EventHandlers.ts
  • scenarios/test_codegen/test/EventHandler_test.ts
📚 Learning: 2025-08-04T07:36:16.824Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:36:16.824Z
Learning: Applies to scenarios/test_codegen/**/*.ts : When updating existing entities, always use the spread operator because returned objects are read-only and immutable

Applied to files:

  • scenarios/test_codegen/src/EventHandlers.ts
  • scenarios/test_codegen/test/EventHandler_test.ts
📚 Learning: 2025-08-04T07:36:16.824Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:36:16.824Z
Learning: Applies to scenarios/test_codegen/**/*.ts : Verify relationship field names match generated types after code changes

Applied to files:

  • scenarios/test_codegen/src/EventHandlers.ts
  • scenarios/test_codegen/test/EventHandler_test.ts
📚 Learning: 2025-08-04T07:36:16.824Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:36:16.824Z
Learning: Applies to scenarios/test_codegen/**/*.ts : When creating new entities, ensure relationships use `entity_id` fields, not direct objects

Applied to files:

  • scenarios/test_codegen/test/EventHandler_test.ts
📚 Learning: 2025-08-04T07:36:16.824Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:36:16.824Z
Learning: Applies to scenarios/test_codegen/**/*.{ts,graphql} : In Envio, use `entity_id` fields (e.g., `token_id: string`) instead of direct object references for relationships

Applied to files:

  • scenarios/test_codegen/test/EventHandler_test.ts
📚 Learning: 2025-08-04T07:36:16.824Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-04T07:36:16.824Z
Learning: Applies to scenarios/test_codegen/**/*.ts : When creating new entities, ensure all required fields are present in the entity object

Applied to files:

  • scenarios/test_codegen/test/EventHandler_test.ts
📚 Learning: 2025-05-27T17:07:12.878Z
Learnt from: JonoPrest
PR: enviodev/hyperindex#555
File: scenarios/test_codegen/test/lib_tests/EntityHistory_test.res:631-659
Timestamp: 2025-05-27T17:07:12.878Z
Learning: In isolated tests for EntityHistory rollbacks with controlled mock data setup, the ordering of getRollbackDiff results is deterministic and doesn't require sorting before comparison with deepStrictEqual.

Applied to files:

  • scenarios/test_codegen/test/EventHandler_test.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_and_test
🔇 Additional comments (6)
scenarios/test_codegen/config.yaml (1)

57-58: Verify ABI declarations and regenerate types

The handlers for FilterTestEvent and WildcardHandlerWithLoader are present in scenarios/test_codegen/src/EventHandlers.ts (lines 676, 688). I couldn’t locate gravatar-abi.json in the repo to confirm the events are declared in your ABI.

  • Ensure your Gravatar ABI includes both new events.
  • After updating your ABI or config.yaml, run pnpm codegen to regenerate bindings.
codegenerator/cli/templates/dynamic/codegen/src/Types.res.hbs (1)

378-386: Option-wrapping eventFilters is correct and fixes wildcard-only registration

Switching to eventFilters: ?eventConfig.eventFilters ensures absence is explicit (None), avoiding truthy/empty pitfalls and fixing wildcard-only cases. Good change.

scenarios/test_codegen/src/EventHandlers.ts (2)

676-686: Filter-based handlerWithLoader wiring looks correct

Handler throws when addr matches filter; this intentionally asserts that test framework currently ignores filters. Filter shape aligns with generated types.

After codegen, run pnpm tsc --noEmit to ensure the generated types accept this eventFilters shape.


688-692: Wildcard handlerWithLoader registration LGTM

Minimal loader/handler with wildcard: true validates the regression fix. No issues.

scenarios/test_codegen/test/EventHandler_test.ts (2)

18-18: Refactor to mockDb.processEvents is consistent; verify ordering and return semantics

Switching to processEvents([event...]) is consistent across tests and matches the API that returns a new MockDb. Batch processing case (Line 265) maintains event order.

If any tests become flaky, double-check that:

  • each call uses the returned DB for subsequent reads/writes, and
  • batched events are ordered as expected.

Also applies to: 48-48, 78-78, 106-106, 139-139, 164-164, 182-182, 200-200, 219-219, 237-237, 265-265, 287-290, 310-310, 339-339


354-375: New tests for filter-ignored behavior and wildcard initialization are precise

  • Asserting rejection for filtered handler confirms current limitation in the test framework.
  • Wildcard handler init test guards against the Caml_option.some regression.

@DZakh
DZakh requested a review from JonoPrest August 8, 2025 11:04
Some({
wildcard: ?eventConfig.wildcard,
eventFilters: eventConfig.eventFilters,
eventFilters: ?eventConfig.eventFilters,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Surely this was a compile time error?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For some reason, it wasn't.

@JonoPrest JonoPrest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🙏🏼

@DZakh
DZakh merged commit 047a2fd into main Aug 11, 2025
2 checks passed
@DZakh
DZakh deleted the dz/fix-handler-with-loader-regression branch August 11, 2025 08:39
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.

2 participants