Repository navigation
fix(#5863): decouple @props type hint emission from includeMetadata in map2json - #5980
Conversation
…n map2json map2json used the includeMetadata parameter to decide whether to emit the @props type-hint string. This bundled @props into every toJSON(true) call, including the WebSocket ChangeEvent broadcast path (and the Redis/Postgres wire-protocol paths, which hit the same map2json call) where no consumer can opt in to receiving it. Mirror the #5860 fix for serializeResult: map2json now gates @props on the serializer-level includeTypeHints field (off by default) instead of includeMetadata, which keeps its original meaning of "include @rid/@type/@cat/@in/@out" identity metadata only. Adds a regression test pinning the off-by-default behavior at the Document API level (mirroring propsHintOffByDefault from #5860) and a ChangeEvent test asserting a broadcast payload never contains @props.
|
Tick the box to add this pull request to the merge queue (same as
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
ReviewThis is a well-scoped fix. I traced every caller of Correctness
Test coverage
Minor / non-blocking observations
Nothing else stood out. I wasn't able to execute Nice catch tracing this back through |
…p2json Per code-review on #5980: serializeResult already migrated to !propertyTypes.isEmpty(), map2json still used the older length() > 0 form. No behavior change.
ReviewSolid, well-scoped fix that mirrors the established Correctness
Tests
Style
Minor notes (non-blocking)
Overall: low risk, good test coverage, no regressions found in the paths that matter (remote save/round-trip, Redis/Postgres wire protocols, WebSocket broadcast). LGTM. |
Description
map2jsonwas using theincludeMetadataparameter to decide whether to emit the@propsper-column JSON type-hint string. This bundled@propsinto everytoJSON(true)call, including theWebSocketEventBus/ChangeEventbroadcast path where no consumer can opt in to receiving it (and, incidentally, the Redis and Postgres wire-protocol paths, which callrecord.toJSON(true)too).The
WebSocketEventBuscallsrecord.toJSON(true)once per change event and broadcasts the resulting JSON string to every connected subscriber. There is no per-subscriber request to key an opt-in off of, so every subscriber got@propson any property whose type is lossy through JSON (SHORT,FLOAT,LONG, temporals, ...) and isn't declared in the schema.Fix
Mirrors the #5860 fix for
serializeResult:map2jsonnow uses the serializer-levelincludeTypeHintsfield (off by default) instead of theincludeMetadataparameter to decide whether to emit@props.includeMetadatakeeps its original meaning: "include@rid/@type/@cat/@in/@out" identity metadata only (unchanged, still handled by theMutableDocument/ImmutableDocument/DetachedDocumentwrappers).@propshint is now emitted only when the caller explicitly enables it viaJsonSerializer.setIncludeTypeHints(true).Regression proof
Reverting just the
JsonSerializer.javachange reproduces the exact leak reported in #5863 - the newChangeEventTestfails with:Tests
JsonSerializerTest#map2jsonPropsHintOffByDefaultForSchemalessLossyProperty- pins the off-by-default behavior at theDocument.toJSON(true)API level (mirrorspropsHintOffByDefaultfrom fix(#5812): make the @props JSON type hint opt-in, off by default #5860).ChangeEventTest#changeEventNeverEmitsPropsHint(new file) - asserts a broadcastChangeEventpayload never contains@props, exercisingChangeEvent/WebSocketEventBusdirectly with no HTTP server needed.JsonSerializerTest,JSONSerializerTest,WebSocketEventBusIT,Issue5024WebSocketEventBusConcurrencyTest, and the fullredisw/postgreswmodule test suites (all green) plus a full reactor compile.Note on #5952
This supersedes #5952 (same fix, opened by @waterWang, thank you for the report and initial patch). That PR's CI failures were unrelated to its one-line change:
claude-reviewfailed on an OIDC-token permission limitation for fork PRs,unit-testshit a pre-existing stale-assertion bug inRangeFunctionTestthat was fixed onmainby #5954 minutes after that PR's CI ran, andintegration-tests/ha-integration-tests/coverage-reportmatch known chronic CI flakes unrelated to this change. This PR adds the test coverage #5952 was missing and confirms the fix against currentmain.Closes #5863