Skip to content

fix: update sceme validation rules + tenderly types#211

Open
limitofzero wants to merge 1 commit intomainfrom
fix/tenderly-validation-scheme-types
Open

fix: update sceme validation rules + tenderly types#211
limitofzero wants to merge 1 commit intomainfrom
fix/tenderly-validation-scheme-types

Conversation

@limitofzero
Copy link
Copy Markdown
Contributor

@limitofzero limitofzero commented Apr 14, 2026

Tenderly simulation runs successfully, but when our BFF tries to serialize the response, Fastify's schema validation fails: The value of '#/items/properties/stateDiff/items/properties/original' does not match schema definition and it returns 500

Summary by CodeRabbit

  • Improvements
    • The simulation bundle endpoint now accepts additional data types for state diff entries, including numbers, booleans, and arrays, alongside existing string and object support.

@limitofzero limitofzero self-assigned this Apr 14, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

📝 Walkthrough

Walkthrough

The StateDiff type definition and its JSON schema validation have been updated to accept number, boolean, and array types for the original and dirty fields, in addition to the previously supported string, object, and null types.

Changes

Cohort / File(s) Summary
StateDiff Type Expansion
libs/repositories/src/repos/SimulationRepository/tenderlyTypes.ts, apps/api/src/app/routes/__chainId/simulation/simulateBundle.ts
Broadened type definitions for StateDiff.original and StateDiff.dirty fields to include number, boolean, and unknown[] types alongside existing string, Record<string, any>, and null.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit's ode to broader bounds:

Once strings alone could hold the state,
But numbers, booleans now integrate,
Arrays join the blessed fold—
Our diffs are flexible and bold! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title mentions updating schema validation rules and Tenderly types, which aligns with the actual changes that update JSON schema validation for stateDiff entries and broaden the StateDiff type definitions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 fix/tenderly-validation-scheme-types

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.

@limitofzero limitofzero requested a review from a team April 14, 2026 16:39
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: 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 `@libs/repositories/src/repos/SimulationRepository/tenderlyTypes.ts`:
- Around line 581-582: The widened types in tenderlyTypes (properties
diff.original and diff.dirty now allow 0/false) break downstream logic in
buildStateDiff.ts that uses truthy checks and ||; update the merge/guard logic
in libs/repositories/src/utils/buildStateDiff.ts to use explicit null/undefined
checks (e.g., diff.original !== undefined && diff.original !== null) and replace
usages of the || operator with nullish coalescing or explicit checks so valid
falsy values (0, false, empty string) are preserved when computing/merging
state; ensure any conditional like if (diff?.original && diff?.dirty) is changed
to test for non-null/undefined values instead.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0bd1daa8-cb77-4f19-ab0d-a84ecabd2f22

📥 Commits

Reviewing files that changed from the base of the PR and between 07f7932 and e554512.

⛔ Files ignored due to path filters (1)
  • libs/repositories/src/gen/cow/cow-api-types.ts is excluded by !**/gen/**
📒 Files selected for processing (2)
  • apps/api/src/app/routes/__chainId/simulation/simulateBundle.ts
  • libs/repositories/src/repos/SimulationRepository/tenderlyTypes.ts

Comment on lines +581 to +582
original: string | number | boolean | Record<string, any> | unknown[] | null;
dirty: string | number | boolean | Record<string, any> | unknown[] | null;
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.

⚠️ Potential issue | 🔴 Critical

Falsy state values will be dropped after this type widening

Line 581 and Line 582 now allow 0/false, but downstream merge logic still uses truthiness (|| and if (diff?.original && diff?.dirty) in libs/repositories/src/utils/buildStateDiff.ts), which will coerce valid values to null or skip processing.

Proposed fix in libs/repositories/src/utils/buildStateDiff.ts
-        original: diff.original || null,
-        dirty: diff.dirty || null,
+        original: diff.original ?? null,
+        dirty: diff.dirty ?? null,
-  if (diff?.soltype && diff?.original && diff?.dirty) {
+  if (
+    diff?.soltype != null &&
+    diff?.original != null &&
+    diff?.dirty != null
+  ) {
     return processRegularDiff(accumulatedStateDiff, diff);
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@libs/repositories/src/repos/SimulationRepository/tenderlyTypes.ts` around
lines 581 - 582, The widened types in tenderlyTypes (properties diff.original
and diff.dirty now allow 0/false) break downstream logic in buildStateDiff.ts
that uses truthy checks and ||; update the merge/guard logic in
libs/repositories/src/utils/buildStateDiff.ts to use explicit null/undefined
checks (e.g., diff.original !== undefined && diff.original !== null) and replace
usages of the || operator with nullish coalescing or explicit checks so valid
falsy values (0, false, empty string) are preserved when computing/merging
state; ensure any conditional like if (diff?.original && diff?.dirty) is changed
to test for non-null/undefined values instead.

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.

1 participant