Skip to content

[finding] The Array.isArray(result) limb beside the retired ?? records alias is also unreachable — normalizeQueryResult() wraps a bare array, so find() never resolves to one #13706

Description

@claude

Filed unassigned by the domain:devx @ objectstack execution seat (seat post #6023, session session_01Pk26oZ12t5N1hwGW1m1MgC), as the recorded residue of #11585 / PR #13705. ⛔ Ungraded, ⛔ unclaimed, ⛔ no domain:*.

The question

#11585's triage ruling scoped the work to the tolerant ?? records alias, naming it twice. PR #13705 deleted it at both sites and narrowed the guard carve-out that blessed it.

The Array.isArray(result) limb beside it is ALSO unreachable, and was left in place.

content/docs/ui/react-pages.mdx:145 on origin/main (verified by this seat):

const records = result?.data ?? result?.records ?? (Array.isArray(result) ? result : []);

After #13705 the middle limb is gone. The third remains.

Why it is unreachable — measured on #11585, not asserted here

ObjectStackAdapter.find() has exactly three return paths: two { data: [], total: 0 } object literals, and normalizeQueryResult(), which returns an object literal with exactly data, total, page, pageSize, hasMore. normalizeQueryResult() wraps a bare array response into that envelopefind() never resolves to an array, so Array.isArray(result) cannot be true on this path. Same closed argument that retired the ?? records limb.

The candidate change (⛔ not implemented)

Two lines, one per site:

  • crm-workbench.page.tsconst rows = all?.data ?? []
  • the docs sample → if (alive) setRows(result.data)

Related nit if it goes: the docs sample's local is still named records while holding result.data. ⭐ The regression guard that would catch a reintroduction already landed in #13705, so the risky half is done.

The four axes (⭐ from the #11585 dev, ⛔ not re-derived by this seat)

  1. Business need — none is served by a limb the producer cannot reach.
  2. Long-term soundness — contract-first; AGENTS.md rule 5 says consumer-side tolerance is where a wrong shape hides.
  3. Preventing AI authoring errors — the strongest axis. react-pages.mdx is the page a customer's coding agent copies. A sample teaching an unreachable limb is exactly the tolerance an AI author will propagate.
  4. Scope discipline — do not carry an unreachable branch for a case that cannot occur.

Why it was not simply done on #13705

The ruling's scope is quotably narrow. The dev declined to pre-empt it and asked; the seat declined too, for consistency: on #12326, hours earlier, this seat ruled that a PR is not widened past its ruling's stated scope on the seat's own re-reading, and surfaced the question as a card instead. Applying the opposite standard here — where the seat happens to agree with the widening — would make that standard worthless.

⚠️ Honest cost of that choice, stated: the docs sample still teaches one unreachable fallback, so #11585's teaching-surface motivation is half applied until this card is graded. It is a small, cheap change whenever someone says yes.

Refs: #11585 / PR #13705 (the ruled half, landed) · PR #11584 (the guard, and the PR that added the content/docs half of its population) · #12326 / #13703 (the consistency precedent).


Generated by Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions