fix: update sceme validation rules + tenderly types#211
fix: update sceme validation rules + tenderly types#211limitofzero wants to merge 1 commit intomainfrom
Conversation
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
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 `@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
⛔ Files ignored due to path filters (1)
libs/repositories/src/gen/cow/cow-api-types.tsis excluded by!**/gen/**
📒 Files selected for processing (2)
apps/api/src/app/routes/__chainId/simulation/simulateBundle.tslibs/repositories/src/repos/SimulationRepository/tenderlyTypes.ts
| original: string | number | boolean | Record<string, any> | unknown[] | null; | ||
| dirty: string | number | boolean | Record<string, any> | unknown[] | null; |
There was a problem hiding this comment.
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.
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