Skip to content

fix(render): surface an error for unhandled renderer tags instead of "[object Object]" - #2874

Open
sagarswamirao wants to merge 1 commit into
malloydata:mainfrom
sagarswamirao:sagark/render-unhandled-tag-error
Open

fix(render): surface an error for unhandled renderer tags instead of "[object Object]"#2874
sagarswamirao wants to merge 1 commit into
malloydata:mainfrom
sagarswamirao:sagark/render-unhandled-tag-error

Conversation

@sagarswamirao

Copy link
Copy Markdown
Contributor

What

When a field carries a renderer tag that resolves to a renderer name but no plugin handles it, the renderer rendered [object Object] (or, once an error was thrown, an empty red error box). This makes both cases surface a clear, inline error message instead.

Why

big_value supports child-only config keys (e.g. sparkline, comparison_field) that are only valid on a basic field inside an activated big_value. If a user instead puts a child-only key on the view itself -- for example:

# big_value { sparkline=monthly_traffic }
view: summary is { ... }

the big_value plugin declines to match (child-only config, no activating big_value on the parent), so no plugin attaches to the field. The Malloy hover/lint already flags this as invalid. But at render time:

  1. shouldRenderAs still maps the big_value tag to renderAs = 'big_value'.
  2. applyRenderer finds no plugin and no switch case for 'big_value', so it hit the default branch.
  3. The default did String(dataColumn.value). For a structured root cell (a record/array), that produced [object Object] filling the entire result panel.

So the hover lint said "this is wrong" but Run SQL rendered garbage. The two should agree -- a misconfigured tag should fail with a visible, actionable error in both places.

While wiring that up, a second, pre-existing bug surfaced: throwing an error produced an empty red box rather than the message. Solid's ErrorBoundary passes the thrown error as the first fallback argument, but the fallback read errorProps.error?.message and otherwise fell through to the error object itself, which renders as nothing when used as a JSX child. That affected all render-time error display, not just this case.

Changes

  • apply-renderer.tsx -- in the default case, render scalar values via String() as before, but throw a descriptive error for structured (object/array) values instead of emitting [object Object].
  • render.tsx -- resolve the ErrorBoundary message from the {error} wrapper, a thrown Error, or a raw string, coercing to a string so the message is always displayed (fixes the empty error box).

Compatibility

Backward compatible. Scalar values still render exactly as before; only the previously-broken [object Object] path now surfaces a visible error, and existing error messages now display instead of an empty box.

Test

jest --selectProjects malloy-render -- 92 passed. Verified end-to-end in the VS Code extension: the misconfigured # big_value { sparkline=... } view now shows Malloy render: no renderer available for 'big_value' on field 'root'. Check the 'big_value' tag -- its configuration may be incomplete or unsupported. instead of [object Object].

…bject Object]"

When a field carries a renderer tag that resolves to a renderer name but no
plugin handles it -- for example `# big_value { sparkline=... }` on a view with
no activating big_value config, where the big_value plugin declines to match --
applyRenderer fell through to its default case and coerced the cell with
String(). For a structured root cell (record/array) that produced
"[object Object]" filling the whole result panel. The Malloy hover/lint already
flags the tag, but running the query rendered garbage.

Two changes:

- apply-renderer: in the default case, render scalar values via String() as
  before, but throw a descriptive error for structured (object/array) values
  rather than emitting "[object Object]".
- render: the ErrorBoundary fallback receives the thrown error as its first
  argument. It read `errorProps.error?.message` and otherwise fell through to
  the error object itself, which renders as nothing when used as a JSX child --
  an empty error box. Resolve the message from the wrapper, a thrown Error, or a
  string, coercing to a string so the message is always displayed.

Backward compatible: scalar values still render exactly as before; only the
previously-broken "[object Object]" path now surfaces a visible error.

Signed-off-by: Sagar Swami Rao Kulkarni <sagarswamirao@gmail.com>
@sagarswamirao
sagarswamirao force-pushed the sagark/render-unhandled-tag-error branch from f296799 to 61b091b Compare June 11, 2026 08:17
mtoy-googly-moogly pushed a commit that referenced this pull request Jun 16, 2026
…gs instead of "[object Object]" (#2892)

A field whose renderer tag resolves to a renderer name that no plugin handles fell through apply-renderer's default branch to String(value); for a structured (record/array) value that produced the literal "[object Object]" filling the result panel. A common case: a child-only `# big_value { sparkline=... }` placed on a view with no activating `# big_value` (the plugin declines to match since #2719). The Malloy lint already flags this, but render time showed garbage.

- When the renderer validator has already flagged the field (e.g. the big_value case), surface its specific message ("Tag 'big_value' on field 'root' is only valid on basic fields inside big_value.") so the user sees exactly what is wrong. FieldBase records error-severity validateFieldTags findings; apply-renderer's default reads them.
- Otherwise, for a structured value with no renderer, surface a generic "no renderer available" message inline. Scalars and the 'none' renderAs keep the existing string fallback, so a chart-child record is not mistaken for an error and one unhandled field does not blank the whole panel.
- render.tsx: the ErrorBoundary fallback now resolves the message from an {error} wrapper, a thrown Error, or a raw string, fixing a pre-existing bug where thrown render errors showed an empty red box.

Adds a misconfigured-big_value Storybook story and a render-validator test.

Combines #2874 (Sagar) and #2875 (Monty).

Signed-off-by: Monty Lennie <montylennie@gmail.com>
Co-authored-by: Sagar Swami Rao Kulkarni <sagarswamirao@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant