Skip to content

[web_core] formatString should JSON-stringify objects/arrays per spec #1386

@BBC6BAE9

Description

@BBC6BAE9

web_core's FormatStringImplementation (renderers/web_core/src/v0_9/basic_catalog/functions/basic_functions.ts) uses Array.prototype.join(''), which falls back to JS's default String(value) for object/array values. This contradicts a2ui_protocol.md §"Type conversion":

Objects/Arrays: Stringified as JSON to ensure consistency across different client implementations.

Related but distinct from #912, which only standardized scalar (null/undefined/Number/Boolean) coercion.

Reproduction

Given a data model:

{
  "tags":   ["swift", "ios"],
  "user":   { "name": "Alice", "age": 30 },
  "matrix": [[1, 2], [3, 4]],
  "vals":   [1, null, 3]
}
Template Spec says web_core actually outputs
"Tags: ${/tags}" Tags: ["swift","ios"] Tags: swift,ios
"User: ${/user}" User: {"name":"Alice","age":30} User: [object Object]
"M = ${/matrix}" M = [[1,2],[3,4]] M = 1,2,3,4 (nested arrays flattened)
"V = ${/vals}" V = [1,null,3] V = 1,,3 (null silently dropped)

The object case is the most damaging: any object value renders as the literal string [object Object], which is essentially data loss.

Impact

Affects web_core and every renderer that re-exports BASIC_FUNCTIONS from it (react, lit, angular).

Metadata

Metadata

Assignees

Labels

type: bugSomething isn't working

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