openai / gpt-6-luna / low / low effort preferred over cursor / composer-2.5 / Composer 2.5 default / unknown effort · close win.
Primary judge: Sol 6.1, requested Low. Effective provider effort and internal attempts were not verified. A close win is still a scored preference; it does not establish a material defect.
Reviewed public evidence
Task goal
Review persisted dashboard-layout parsing and its DashboardBuilderPage/BuilderCanvas consumers for a reproducible runtime crash caused by malformed widget shapes. Use only the supplied source files and the linked read-only reproduction. Establish the exact malformed shapes accepted by parseLayout and the resulting consumer failure; distinguish established behavior from assumptions. Recommend the smallest compatible correction that preserves valid stored layouts and custom widget data, plus focused regression tests. If the evidence does not establish the defect or a safe correction, state that clearly. Do not edit source or run tests.
Exact read-only reproduction stdout:
{"input":"[null]","parserOk":true,"canvasProjectionError":"TypeError: Cannot read properties of null (reading 'position')"}
{"input":"[{\"id\":\"w1\",\"type\":\"kpi_card\"}]","parserOk":true,"canvasProjectionError":"TypeError: Cannot read properties of undefined (reading 'x')"}
{"input":"[{\"id\":\"w1\",\"type\":\"kpi_card\",\"position\":{\"x\":0,\"y\":0,\"w\":4,\"h\":2}}]","parserOk":true,"canvasProjection":[0]}openai / gpt-6-luna / low / low effort answer
**Conclusion (high confidence):** The supplied reproduction and source establish a runtime crash when persisted JSON is an array containing either `null` or a widget without `position`.
- `parseLayout` checks only that the parsed value is an array, then casts its elements to `WidgetConfig[]` without validating them (`parseLayout.ts:13–18`). Thus both `[null]` and `[{"id":"w1","type":"kpi_card"}]` are accepted.
- `DashboardBuilderPage` installs any successful parse as `widgets` (`DashboardBuilderPage.tsx:55–74, 130–146`). Nonempty widgets render `BuilderCanvas` (`:451–480`).
- `BuilderCanvas` projects every item by reading `w.position.x` and the other position fields (`BuilderCanvas.tsx:40–54`). The supplied reproduction confirms the resulting errors for `null` and missing `position`. A widget with the shown complete position projects successfully.
- The evidence does **not** establish that every malformed widget shape crashes, nor does the third reproduction establish validation of position values or the rest of a widget’s fields.
**Smallest compatible correction:** Validate the parsed array’s structural requirements before returning success, while preserving each valid widget object unchanged—including unknown/custom fields. Reject malformed entries through an explicit error result so the existing page’s invalid-layout banner and save block apply. Avoid rebuilding widgets from a whitelist, which could discard custom data. The packet does not establish the full minimum valid widget schema; requiring only non-null objects and a usable `position` object with `x`, `y`, `w`, and `h` addresses these demonstrated crashes, but numeric/range requirements need an explicit compatibility decision.
**Focused regression tests:** Add parser cases for `[null]` and a widget missing `position`, asserting they are rejected; keep a valid positioned widget case asserting success and preservation of an extra custom field. Add or retain a consumer-level regression showing rejected persisted data does not reach the canvas. Existing tests cover JSON syntax and top-level array shape only (`parseLayout.test.ts:12–61`).
**Uncertainty:** `WidgetConfig` declares required fields (`dashboards.ts:40–55`), but the supplied evidence does not show backend layout contracts or all widget/custom-data conventions. The exact read-only reproduction establishes the two failures, not broader schema constraints.cursor / composer-2.5 / Composer 2.5 default / unknown effort answer
## Evidence packet: malformed `layout_json` → `parseLayout` accepts → `BuilderCanvas` crashes
### 1. Conclusion, evidence, implications, confidence
**Defect is established** for a reproducible runtime crash when persisted `layout_json` is a JSON **array** whose elements are not usable `WidgetConfig` shapes for the builder canvas. `parseLayout` only checks `JSON.parse` + `Array.isArray`; it does **not** validate elements. On `ok: true`, `DashboardBuilderPage` assigns `result.widgets` to state and renders `BuilderCanvas`, which **unconditionally** reads `w.position.x` (and siblings) in a `useMemo`.
| Malformed input (reproduction) | `parseLayout` | Consumer failure (reproduction) |
|-------------------------------|---------------|----------------------------------|
| `[null]` | `ok: true` | `TypeError: Cannot read properties of null (reading 'position')` |
| `[{"id":"w1","type":"kpi_card"}]` (no `position`) | `ok: true` | `TypeError: Cannot read properties of undefined (reading 'x')` |
| Full widget with `position: {x,y,w,h}` | `ok: true` | Projection succeeds (`canvasProjection: [0]`) |
**Source chain (no tools; packet only):**
```13:17:[REDACTED: private project name]/frontend/src/lib/parseLayout.ts
export function parseLayout(layout_json: string): LayoutResult {
try {
const parsed = JSON.parse(layout_json)
if (!Array.isArray(parsed)) return { ok: false, error: 'not_array' }
return { ok: true, widgets: parsed as WidgetConfig[] }
```
```40:47:[REDACTED: private project name]/frontend/src/components/dashboard/BuilderCanvas.tsx
const layout: Layout = useMemo(
() =>
widgets.map((w) => ({
i: w.id,
x: w.position.x,
y: w.position.y,
w: w.position.w,
h: w.position.h,
```
```59:62:[REDACTED: private project name]/frontend/src/pages/DashboardBuilderPage.tsx
const result = parseLayout(urlConfig.layout_json)
if (result.ok) {
setWidgets(result.widgets)
setLayoutError(null)
```
```32:32:[REDACTED: private project name]/frontend/src/pages/DashboardBuilderPage.tsx
const [layoutError, setLayoutError] = useState<'invalid_json' | 'not_array' | null>(null)
```
**Implications:** Any stored dashboard whose `layout_json` parses to an array but contains `null`, non-objects, or objects without a `position` object with numeric `x/y/w/h` can load with `layoutError === null`, show the builder (when `widgets.length > 0`), and **throw during render** in `BuilderCanvas`’s layout projection. Save is **not** blocked for these cases (`saveBlocked` only when `layoutError !== null`), unlike true JSON/array errors.
**Confidence:** **High** for the two malformed shapes above and the exact error strings (reproduction stdout + cited lines). **High** that the crash site is `w.position` / `w.position.x` in `BuilderCanvas` given those errors.
**Broader malformed shapes accepted by `parseLayout` (logical extension of the same guard, not individually reproduced in stdout):** any array element that is not a plain object with a `position` object exposing `x`, `y`, `w`, `h` as readable properties—e.g. `position: null`, `position: {}`, `position: { x: 0 }`, primitives in the array, arrays as elements—should still yield `ok: true` and fail at the same projection (or adjacent property access on `w`). **Not established** in the packet: whether `WidgetRenderer` throws earlier/later for missing `title`/`config`/`type` (dependency outside packet).
---
### 2. Alternatives / discarded hypotheses
| Hypothesis | Verdict |
|------------|--------|
| Crash is from `invalid_json` / `not_array` paths | **Discarded** — reproduction shows `parserOk: true` for failing inputs. |
| `DashboardBuilderPage` already blocks corrupt layouts | **Partially false** — banner + `saveBlocked` apply only to `invalid_json` and `not_array`, not element-shape errors. |
| Fix only in `BuilderCanvas` (optional chaining / defaults) | **Insufficient alone** — avoids throw but silently feeds bad data to RGL; does not align with explicit error UI for corrupt **saved** layouts; may hide bad persisted data. |
| Filter invalid elements, return `ok: true` with subset | **Riskier** — preserves some widgets but **drops** persisted entries without user-visible “corrupt layout” flow; conflicts with existing “invalid layout → Start fresh” pattern unless separately surfaced. |
| Strict full `WidgetConfig` validation (`title`, `config`, etc.) | **Possible but wider scope** — may reject layouts that are recoverable in the editor if only `position` is wrong; not required to fix the **established** crash. |
---
### 3. Missing evidence / consequences
- **`WidgetRenderer` / `WidgetConfig` from `./WidgetRenderer`** — not in packet; unknown whether missing `title`/`config` causes additional crashes after layout projection is fixed.
- **Other readers of `layout_json`** (runtime dashboard view, API validation) — unknown; fixing `parseLayout` affects all callers of that function (at least URL load and `loadSavedConfig` in this packet).
- **`getDefaultWidgetSize` / templates** — not shown producing malformed layouts; defect is framed as **persisted** malformed arrays, which the parser currently admits.
---
### 4. Smallest compatible correction (recommendation)
**Extend `parseLayout` with minimal structural validation** after the array check, before returning `ok: true`:
- Reject the layout (new discriminant, e.g. `error: 'invalid_widgets'`) if **any** element fails:
- `item != null` and `typeof item === 'object'` and not `Array.isArray(item)`
- `typeof item.id === 'string'` and `item.id.length > 0` (matches builder’s use of `w.id` as RGL `i` and React `key`)
- `item.position != null` and `typeof item.position === 'object'`
- `['x','y','w','h'].every(k => typeof item.position[k] === 'number' && Number.isFinite(item.position[k]))`
- Do **not** strip or rewrite `config`, extra keys, or optional fields—only gate `ok`. Valid complete layouts (as in existing test and reproduction case 3) remain `ok: true` with widgets passed through unchanged (still `parsed as WidgetConfig[]` / shallow copy optional, not required).
**Wire consumers (small, compatible):**
- Add `'invalid_widgets'` to `LayoutResult` and to `layoutError` state in `DashboardBuilderPage`; reuse the existing corrupt-layout banner with a third message string (same “Start fresh” behavior as other layout errors).
- No change required to `BuilderCanvas` for the established defect if bad layouts never reach it.
This preserves **valid** stored layouts and **all** custom fields on valid elements; invalid persisted arrays get **non-crashing** error UI instead of a white screen.
**Focused regression tests** (in `parseLayout.test.ts`, matching existing style):
1. `[null]` → `ok: false`, `error: 'invalid_widgets'` (or chosen code).
2. `[{"id":"w1","type":"kpi_card"}]` → same.
3. Existing happy path unchanged (full widget with `position`).
4. `[]` → still `ok: true`.
5. Optional high-value cases: mixed `[valid, invalid]` → fail whole layout (consistent with strict corrupt handling); `position: null`; non-finite numbers.
**Do not** claim tests were run; user forbade execution.
---
### 5. Next useful action
Implement the `parseLayout` element guard + `invalid_widgets` discriminant, extend `DashboardBuilderPage` `layoutError` typing and banner copy, and add the regression cases above; optionally add a tiny pure helper test that mirrors the reproduction’s “canvas projection” `map` over `result.widgets` only for the three stdout inputs to lock the crash class without mounting React.
**Uncertainty note:** If product policy prefers **partial recovery** (load good widgets, drop bad ones), that is a different contract than the page’s current binary corrupt-layout UX; the packet supports **reject-with-banner** as the smallest match to existing behavior.Primary judge's stated reason
B is preferred because its narrower crash claim better separates demonstrated exceptions from merely malformed values, reducing the risk of treating unproved downstream behavior as established. A's more concrete implementation guidance counterbalances this advantage. The preference is weak, not proof of a material overall quality gap; an independent review could reasonably weigh that tradeoff differently.
This reason is the judge's assessment. No independent factual-defect finding is asserted by this record.
Battle wave: 1ac788c7-8a93-4502-8b1a-e4734c703741. Pair: brp1_da3a04dd4a0e642312f1d7dd0bca5918651d96ba99f32792ac4f2c7f54482dad. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.