fix(search): one result without a label no longer fails record search #57

Merged
KofTwentyTwo merged 1 commits from fix/record-search-tolerant-results into main 2026-10-12 13:35:13 +00:00
KofTwentyTwo commented 2026-10-12 10:26:11 +00:00 (Migrated from github.com)

Problem (prod, admin.kof22.com, 2026-10-12)

/app/search?q=maes showed "Record search failed. Try again." plus a "Something went wrong" toast. POST /qqq/v1/search returned 200, 846 bytes (Traefik access log), and the backend logged nothing.

Root cause: two matching page_section records have an empty name, so their record label is "". QQQ serializes JSON with NON_EMPTY and leaves recordLabel out. RecordSearchResponseSchema required recordLabel on every result, so one such result rejected the whole response.

Fix

  • RecordSearchResultSchema: tableName and recordId are required (non-empty); recordId may be a number (converted to a string). tableLabel and recordLabel may be missing, null or empty.
  • searchRecords checks the { results: [] } envelope strictly, then validates each result on its own:
    • A result without a label is labeled "{table label} {record id}".
    • A result that can't link to a record is skipped with console.warn, and the other results still render.
  • The RecordSearchResult type and the hook/page contract are unchanged, so this is safe to build the search UX redesign on.

Server side: QRun-IO/qqq#1068 never emits a blank label and logs every search (outcome, provider, timing).

Tests

  • schemas.test: missing/null/empty labels accepted; numeric recordId accepted; empty tableName/recordId rejected; the envelope no longer fails on one bad result.
  • tables.test: the prod "maes" response shape now resolves with fallback labels; a malformed result is skipped with a warning.
  • The 5 new tests fail on RC.13 code and pass here. vitest (api, layout, hooks): 415 passed. tsc clean.

🤖 Generated with Claude Code

## Problem (prod, admin.kof22.com, 2026-10-12) `/app/search?q=maes` showed **"Record search failed. Try again."** plus a "Something went wrong" toast. `POST /qqq/v1/search` returned **200, 846 bytes** (Traefik access log), and the backend logged nothing. Root cause: two matching `page_section` records have an empty name, so their record label is `""`. QQQ serializes JSON with `NON_EMPTY` and leaves `recordLabel` out. `RecordSearchResponseSchema` required `recordLabel` on every result, so one such result rejected the whole response. ## Fix - `RecordSearchResultSchema`: `tableName` and `recordId` are required (non-empty); `recordId` may be a number (converted to a string). `tableLabel` and `recordLabel` may be missing, null or empty. - `searchRecords` checks the `{ results: [] }` envelope strictly, then validates each result on its own: - A result without a label is labeled `"{table label} {record id}"`. - A result that can't link to a record is skipped with `console.warn`, and the other results still render. - The `RecordSearchResult` type and the hook/page contract are unchanged, so this is safe to build the search UX redesign on. Server side: QRun-IO/qqq#1068 never emits a blank label and logs every search (outcome, provider, timing). ## Tests - schemas.test: missing/null/empty labels accepted; numeric recordId accepted; empty tableName/recordId rejected; the envelope no longer fails on one bad result. - tables.test: the prod "maes" response shape now resolves with fallback labels; a malformed result is skipped with a warning. - The 5 new tests fail on RC.13 code and pass here. `vitest` (api, layout, hooks): 415 passed. `tsc` clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
KofTwentyTwo commented 2026-10-12 13:35:29 +00:00 (Migrated from github.com)

Merged on the owner's explicit approval ("Merge #57 despite NAV-056") with one known pre-existing failure: acceptance (webkit) NAV-056, which also fails on main since #53 and is tracked separately (qqq#985 comment 6122410722). All other checks green. Fixes production global search failing on blank record labels.

🤖 Generated with Claude Code

Merged on the owner's explicit approval ("Merge #57 despite NAV-056") with one known pre-existing failure: acceptance (webkit) NAV-056, which also fails on `main` since #53 and is tracked separately (qqq#985 comment 6122410722). All other checks green. Fixes production global search failing on blank record labels. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.