Skip to content

[Angular] TypeError: Cannot read properties of null (reading 'componentId') in ComponentBinder when resolving children #1477

@josemontespg

Description

@josemontespg

Bug Description

When rendering components in the Angular v0.9 renderer, a TypeError is thrown in the ComponentBinder service:

TypeError: Cannot read properties of null (reading 'componentId')

This occurs when a component defines its children (or other child properties) as null or undefined (for example, a container component that is rendered without any children).

Example JSON Payload (Triggering the bug)

Here is an example A2UI response payload that triggers this crash when the Angular renderer tries to bind properties for the Column component (because its children is null):

{
  "version": "v0.9",
  "updateComponents": {
    "surfaceId": "main-surface",
    "components": [
      {
        "id": "main-layout",
        "component": "Column",
        "children": null
      }
    ]
  }
}

Similarly, if children is omitted entirely from the component properties, also triggering a dereferencing crash on undefined:

{
  "version": "v0.9",
  "updateComponents": {
    "surfaceId": "main-surface",
    "components": [
      {
        "id": "main-layout",
        "component": "Column"
      }
    ]
  }
}

Root Cause

In ComponentBinder.bind():

      } else if (key === 'children') {
        const originalSig = preactSig;
        const id = value.componentId;
        const path = value.path;

When the component does not have any children defined, the value of value (the children property) is null or undefined. Directly dereferencing value.componentId or value.path throws the TypeError.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions