[BUG]: web_core: MessageProcessor.processUpdateDataModelOp omits preserveNull on pre-1.0 surfaces
- [x] I have searched the existing issues to make sure this bug has not already been reported.
Describe the Bug
MessageProcessor.processUpdateDataModelOp calls surface.dataModel.set(path, value) without passing preserveNull, causing explicit null values at non-root paths to delete keys on pre-1.0 (v0.8, v0.9, v0.9.1) surfaces instead of storing null.
DataModel.set(path, value, preserveNull = false) relies on preserveNull to distinguish pre-1.0 vs v1.0 null semantics:
preserveNull = true(pre-1.0): storesnullas an explicit value.preserveNull = false(v1.0+, default): removes the key whenpathis not'/'.
Because processUpdateDataModelOp omits preserveNull:
- Updating the root (
path: '/',value: { field: null }) preservesnull(becauseDataModel.setclones the root object whensegments.length === 0). - Updating a non-root path (
path: '/field',value: null) on av0.9/v0.9.1surface silently removesfieldinstead of storingnull.
Steps to Reproduce
- Create a
MessageProcessorwith a pre-1.0 catalog (e.g.0.9) and run the following snippet:
import { Catalog, MessageProcessor } from '@a2ui/web_core';
const v09Catalog = new Catalog('https://example.com/v09/catalog.json', '0.9', []);
const processor = new MessageProcessor([v09Catalog]);
processor.processMessages([
{
version: 'v0.9',
createSurface: {
surfaceId: 's1',
catalogId: v09Catalog.id,
},
},
{
version: 'v0.9',
updateDataModel: {
surfaceId: 's1',
path: '/field',
value: 'initial',
},
},
{
version: 'v0.9',
updateDataModel: {
surfaceId: 's1',
path: '/field',
value: null,
},
},
]);
console.log(processor.model.getSurface('s1')?.dataModel.get('/'));
- Observe the resulting data model on surface
's1'.
Expected Behavior
On pre-1.0 surfaces (v0.8, v0.9, v0.9.1), processor.model.getSurface('s1')?.dataModel.get('/') should return { field: null }.
MessageProcessor.processUpdateDataModelOp should pass preserveNull = Boolean(surface.protocolVersion && !isAtLeastVersion(surface.protocolVersion, '1.0')) to surface.dataModel.set(), consistent with DataContext.set().
Screenshots / Video / Logs
Actual output from the reproduction above on unpatched @a2ui/[email protected]:
{}
Environment Details
- OS: Platform-independent (reproduced on Windows / Linux)
- Browser/Platform: Node.js / Browser (core
MessageProcessorlogic) - SDK/Package Name & Version:
@a2ui/web_core0.16.1(also present onmain) - Protocol Version:
v0.9/v0.9.1(pre-1.0) - Agent Framework & LLM Model: N/A (reproducible directly with
MessageProcessor)
Additional Context
DataContext.set()already handles this based onsurfaceProtocolVersion(introduced in #3658):const preserveNull = Boolean(this.surfaceProtocolVersion && !this.atLeastV10); this.dataModel.set(absolutePath, value, preserveNull);- In
MessageProcessor.processCreateSurfaceOp, thekey === ''branch checksisAtLeastVersion(surface.protocolVersion, '1.0')when handlingnull, whereasprocessUpdateDataModelOpdoes not passpreserveNull.
From triage bot, analysis:
For humans
TL;DR
Case: this issue reports a confirmed bug in web_core null handling on pre-1.0 surfaces.
Suggestion: set P2.
Summary:
On v0.8 and v0.9 surfaces, an updateDataModel message that sets a non-root path to null removes the key from the data model instead of storing null. The report includes a short MessageProcessor snippet that reproduces it on @a2ui/web_core 0.16.1.
Why flagged for triage: This issue has no priority label.
Suggestion:
- Diagnosed from the code on
main:processUpdateDataModelOpcallsDataModel.setwithoutpreserveNull, soDataModel.setremoves the key.DataContext.setpasses it since #3658. - P2: only pre-1.0 surfaces, and the v0.9 spec turns both
nulland a missing value into an empty string, so the difference shows mainly insendDataModelpayloads. gspencergoogwrote #3658 and 10 of the last 20 commits tomessage-processor.ts. Open #4452 also changes that file.
- Add labels:
type: bug,P2,component: core sdk,status: first-line-handled - Related items: #3658, #4452
Reply:
From triage:
Thanks for the clear report and the reproduction. The code on
mainmatches your diagnosis:processUpdateDataModelOpdoes not passpreserveNull, unlikeDataContext.set. Setting P2, since it affects only pre-1.0 surfaces.
To adjust the analysis and apply its suggestion, open it in the hosted triage UI, or run in your a2ui checkout:
tools/internal/triage/triage_ui.sh https://github.com/a2ui-project/a2ui/issues/4525
For software
<a2ui>
root = TriageAnalysis(
tldr="""Case: this issue reports a confirmed bug in `web_core` null handling on pre-1.0 surfaces.
Suggestion: set P2.""",
summary="""On v0.8 and v0.9 surfaces, an `updateDataModel` message that sets a non-root path to `null` removes the key from the data model instead of storing `null`. The report includes a short `MessageProcessor` snippet that reproduces it on `@a2ui/web_core` 0.16.1.""",
reason="This issue has no priority label.",
suggestion="""- Diagnosed from the code on `main`: [`processUpdateDataModelOp`](https://github.com/a2ui-project/a2ui/blob/9319cedd44ba9b0739afc5d2cf65460c9abe63b4/typescript/core/web_core/src/processing/message-processor.ts#L1869) calls `DataModel.set` without `preserveNull`, so [`DataModel.set`](https://github.com/a2ui-project/a2ui/blob/9319cedd44ba9b0739afc5d2cf65460c9abe63b4/typescript/core/web_core/src/state/data-model.ts#L151) removes the key. [`DataContext.set`](https://github.com/a2ui-project/a2ui/blob/9319cedd44ba9b0739afc5d2cf65460c9abe63b4/typescript/core/web_core/src/resolution/data-context.ts#L517-L518) passes it since [#3658](https://github.com/a2ui-project/a2ui/pull/3658).
- P2: only pre-1.0 surfaces, and the v0.9 spec [turns](https://github.com/a2ui-project/a2ui/blob/9319cedd44ba9b0739afc5d2cf65460c9abe63b4/specification/v0_9/docs/a2ui_protocol.md?plain=1#L478) both `null` and a missing value into an empty string, so the difference shows mainly in `sendDataModel` payloads.
- `gspencergoog` wrote [#3658](https://github.com/a2ui-project/a2ui/pull/3658) and [10 of the last 20 commits](https://github.com/a2ui-project/a2ui/commits/main/typescript/core/web_core/src/processing/message-processor.ts) to `message-processor.ts`. Open [#4452](https://github.com/a2ui-project/a2ui/pull/4452) also changes that file.""",
reply="""Thanks for the clear report and the reproduction. The code on `main` matches your diagnosis: [`processUpdateDataModelOp`](https://github.com/a2ui-project/a2ui/blob/9319cedd44ba9b0739afc5d2cf65460c9abe63b4/typescript/core/web_core/src/processing/message-processor.ts#L1869) does not pass `preserveNull`, unlike [`DataContext.set`](https://github.com/a2ui-project/a2ui/blob/9319cedd44ba9b0739afc5d2cf65460c9abe63b4/typescript/core/web_core/src/resolution/data-context.ts#L517-L518). Setting P2, since it affects only pre-1.0 surfaces.""",
added_labels=["type: bug", "P2", "component: core sdk", "status: first-line-handled"],
related_items=[3658, 4452]
)
</a2ui>
This analysis is auto-created to help humans to triage this item. Please, do not treat it as a team decision.
Hi! I reproduced this and I'm working on a fix with a regression test.
From triage bot, analysis:
For humans
TL;DR
Case: this issue reports a confirmed bug in web_core null handling on pre-1.0 surfaces, and an out-of-team contributor opened a fix.
Suggestion: set P2.
Summary:
On v0.8 and v0.9 surfaces, an updateDataModel message that sets a non-root path to null removes the key from the data model instead of storing null. The report includes a short MessageProcessor snippet that reproduces it on @a2ui/web_core 0.16.1.
Targeting PRs: https://github.com/a2ui-project/a2ui/pull/4537
Why flagged for triage: This issue has no priority label.
Suggestion:
- Diagnosed from the code on
main:processUpdateDataModelOpcallsDataModel.setwithoutpreserveNull, unlikeDataContext.set. - P2: only pre-1.0 surfaces, and the v0.9 spec turns both
nulland a missing value into an empty string. AndresDvstsaid they reproduced it, and opened #4537, which closes this issue: a three-file fix with a regression test. Triage the PR separately;gspencergoog, who wrote #3658, is the expert. Open #4452 also changesmessage-processor.ts.
- Add labels:
type: bug,P2,component: core sdk,status: first-line-handled - Related items: #3658, #4452
Reply:
From triage:
Thanks for the clear report and the reproduction. The code on
mainmatches your diagnosis:processUpdateDataModelOpdoes not passpreserveNull, unlikeDataContext.set. Setting P2, since it affects only pre-1.0 surfaces. Thanks,AndresDvst, for opening #4537; the team will triage it separately.
To adjust the analysis and apply its suggestion, open it in the hosted triage UI, or run in your a2ui checkout:
tools/internal/triage/triage_ui.sh https://github.com/a2ui-project/a2ui/issues/4525
For software
<a2ui>
root = TriageAnalysis(
tldr="""Case: this issue reports a confirmed bug in `web_core` null handling on pre-1.0 surfaces, and an out-of-team contributor opened a fix.
Suggestion: set P2.""",
summary="""On v0.8 and v0.9 surfaces, an `updateDataModel` message that sets a non-root path to `null` removes the key from the data model instead of storing `null`. The report includes a short `MessageProcessor` snippet that reproduces it on `@a2ui/web_core` 0.16.1.""",
reason="This issue has no priority label.",
suggestion="""- Diagnosed from the code on `main`: [`processUpdateDataModelOp`](https://github.com/a2ui-project/a2ui/blob/9319cedd44ba9b0739afc5d2cf65460c9abe63b4/typescript/core/web_core/src/processing/message-processor.ts#L1869) calls `DataModel.set` without `preserveNull`, unlike [`DataContext.set`](https://github.com/a2ui-project/a2ui/blob/9319cedd44ba9b0739afc5d2cf65460c9abe63b4/typescript/core/web_core/src/resolution/data-context.ts#L517-L518).
- P2: only pre-1.0 surfaces, and the v0.9 spec [turns](https://github.com/a2ui-project/a2ui/blob/9319cedd44ba9b0739afc5d2cf65460c9abe63b4/specification/v0_9/docs/a2ui_protocol.md?plain=1#L478) both `null` and a missing value into an empty string.
- `AndresDvst` [said](https://github.com/a2ui-project/a2ui/issues/4525#issuecomment-7344308771) they reproduced it, and opened [#4537](https://github.com/a2ui-project/a2ui/pull/4537), which closes this issue: a three-file fix with a regression test. Triage the PR separately; `gspencergoog`, who wrote [#3658](https://github.com/a2ui-project/a2ui/pull/3658), is the expert. Open [#4452](https://github.com/a2ui-project/a2ui/pull/4452) also changes `message-processor.ts`.""",
reply="""Thanks for the clear report and the reproduction. The code on `main` matches your diagnosis: [`processUpdateDataModelOp`](https://github.com/a2ui-project/a2ui/blob/9319cedd44ba9b0739afc5d2cf65460c9abe63b4/typescript/core/web_core/src/processing/message-processor.ts#L1869) does not pass `preserveNull`, unlike [`DataContext.set`](https://github.com/a2ui-project/a2ui/blob/9319cedd44ba9b0739afc5d2cf65460c9abe63b4/typescript/core/web_core/src/resolution/data-context.ts#L517-L518). Setting P2, since it affects only pre-1.0 surfaces. Thanks, `AndresDvst`, for opening [#4537](https://github.com/a2ui-project/a2ui/pull/4537); the team will triage it separately.""",
added_labels=["type: bug", "P2", "component: core sdk", "status: first-line-handled"],
targeting_prs=[4537],
related_items=[3658, 4452]
)
</a2ui>
This analysis is auto-created to help humans to triage this item. Please, do not treat it as a team decision.