Fix serialization of zero-parameter events in raw_events - #1356
Merged
Conversation
Add a failing test that captures the issue: the decoder produces an
empty object `{}` for zero-parameter events, but buildParamsSchema([])
builds a schema expecting unit/null, so RawEvent.make's reverse
conversion throws "Expected undefined, received {}".
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WNLV8wTTY4D4mJmSTvkf4m
Replace the manufactured `%raw({})` repro with an end-to-end test that
decodes a real `event Empty()` log through the native HyperSync decoder,
which produces the empty object `{}`, then serializes it via
paramsRawEventSchema (the raw_events write path). buildParamsSchema([])
builds a schema expecting unit/null, so the reverse conversion throws
"Expected undefined, received {}" on the real decoder output.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WNLV8wTTY4D4mJmSTvkf4m
Instead of hand-rolling the raw-event serialization with
buildParamsSchema + reverseConvertToJsonOrThrow, decode a real
`event Empty()` log via the native decoder (which yields `{}`) and feed
the result through the real ecosystem.toRawEvent path. The crash now
surfaces from RawEvent.make exactly as it does in production.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WNLV8wTTY4D4mJmSTvkf4m
With raw_events enabled, a zero-parameter event crashed the batch write:
the native decoder hands toRawEvent an empty object `{}`, but the
paramsRawEventSchema is built to expect no params, so reverse conversion
threw "Expected undefined, received {}".
Short-circuit empty params in RawEvent.make to the existing "null"
sentinel before attempting conversion, and turn the prior repro into a
passing regression test.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WNLV8wTTY4D4mJmSTvkf4m
Treat unit/undefined and empty objects uniformly as empty params via a single isEmptyParams check, dropping the redundant post-conversion null-sentinel branch. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WNLV8wTTY4D4mJmSTvkf4m
Move empty-params handling into buildParamsSchema, the only place that
knows (from the param metadata) that an event has no params: the empty
branch now serializes any decoded value to null, so the empty object `{}`
the decoder emits no longer crashes reverse conversion. RawEvent.make's
existing null->"null" sentinel handles the non-null params column
unchanged.
MockIndexer's evm event configs now build their params schemas via the
real EventConfigBuilder instead of a hardcoded copy, so the regression
test exercises the actual schema.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WNLV8wTTY4D4mJmSTvkf4m
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesZero-param event params serialization fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
Keep buildParamsSchema using shape and move the zero-parameter handling into the raw-event make logic: when the decoded params are empty, store the "null" sentinel directly instead of reverse-converting (which the schema rejects for the empty object the decoder emits). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WNLV8wTTY4D4mJmSTvkf4m
Only EVM events hit the crash (SVM rejects raw events; Fuel params use S.json, which serializes the empty object fine). Move the check out of the shared RawEvent.make into Evm.toRawEvent, where the config is an evmEventConfig: when paramsMetadata is empty, pass unit so the existing schema + null sentinel produce "null". RawEvent.make stays generic and Fuel's empty-struct params are no longer rewritten to "null". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WNLV8wTTY4D4mJmSTvkf4m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a regression where zero-parameter events were not being serialized correctly for the raw_events table. The native decoder returns an empty object
{}for events with no parameters, but the raw_events table expectsnullfor the params field.Changes
EventConfigBuilder.res: Updated
buildParamsSchemato use a transform serializer that converts any decoded value (including{}) tonullfor zero-parameter events, instead of relying on a magic cast that didn't properly handle serialization.MockIndexer.res: Updated test helper configurations to use
EventConfigBuilder.buildParamsSchema([])andEventConfigBuilder.buildSimulateParamsSchema([])instead of manually constructing schemas with magic casts, ensuring consistency with the fixed implementation.HyperSyncDecoder_test.res: Added regression test that verifies
toRawEventcorrectly serializes empty params decoded by the native decoder without crashing the batch write.Implementation Details
The fix uses
S.transformwith a serializer function to ensure that regardless of what value the decoder produces for zero-parameter events, it gets serialized asnullin the raw_events table. This maintains the contract that raw_events storesnullfor events with no parameters while allowing the decoder to emit{}.https://claude.ai/code/session_01WNLV8wTTY4D4mJmSTvkf4m
Summary by CodeRabbit
Bug Fixes
Tests