Skip to content

fix(search): restore narrow title lookups - #67

Merged
blurbery merged 1 commit into
mainfrom
hotfix/postgres-search-parameter-types
Aug 29, 2026
Merged

fix(search): restore narrow title lookups#67
blurbery merged 1 commit into
mainfrom
hotfix/postgres-search-parameter-types

Conversation

@blurbery

Copy link
Copy Markdown
Owner

Summary

  • explicitly type the bound PostgreSQL search text when narrow title lookup suppresses the overview branch
  • restore exact and leading-title searches ending in one to three characters, including Breaking Bad, Who Are You?, Up, and typeahead states such as the m
  • distinguish confirmed-empty local results from loading, placeholder, and failed searches before showing Not in your library
  • clarify quota_exceeded as Request limit reached
  • show Movie or Series on request cards so same-title entities remain distinguishable

Root cause

The mixed PostgreSQL builder always bound $1 as search text and $2 as the title-prefix tsquery. Narrow title searches deliberately remove the overview branch to avoid broad scans. That branch was the only reference that gave $1 a PostgreSQL type, leaving generated SQL that referenced $2 and later parameters but never typed $1. PostgreSQL rejected those statements during parse with SQLSTATE 42P18.

breaking used normal FTS and worked. Breaking Bad ended in a three-character token, selected the indexed leading-title path, and failed before execution.

Performance and resource safety

  • The fix adds only $1::text IS NOT NULL as a parameter-only post-filter on narrow paths. It does not change title predicates, candidate counts, ordering, pagination, or hydration.
  • PostgreSQL can plan the guard as a one-time filter; the existing exact B-tree and prefix/GIN paths remain intact.
  • The existing 3-second PostgreSQL search deadline, capped 50-row fuzzy contribution, four aliases per fuzzy candidate, bounded token/edit work, request cancellation, and transaction rollback bounds remain unchanged.
  • Interactive browser query entries retain the existing 30-second garbage-collection window and retry suppression. No unbounded server-side result cache, catalog-sized application index, background worker, or new service was introduced.

Before / after benchmark target

Case Before build 110 Expected after this PR
Breaking Bad local lookup 0% success; HTTP 500 in roughly 9-20 ms; 42P18 HTTP 200 with the indexed local series result
breaking local lookup HTTP 200 and fast unchanged
Failed-query CPU / memory query rejected immediately; no runaway observed bounded normal lookup; no retained worker

The PR will be updated with live response-time, repeated-search resource, and browser layout results from the exact merged image before deployment is declared complete.

Validation

  • focused Go search suite: pass
  • narrow-path matrix covers mixed, media-only, episode-only, multi-word final-short-token, and exact short-title SQL; both page and count statements are asserted
  • focused Web suite: 69 tests pass across catalog lifecycle, global search, request discovery, and request cards
  • TypeScript project check: pass
  • targeted ESLint: 0 errors
  • formatting and git diff --check: pass
  • production read-only identity check: local Breaking Bad series has consistent TMDB, TVDB, IMDb, and provider-ID records; the remaining outside-library same-title result is a distinct movie, so no unsafe title-only deduplication is used

@blurbery
blurbery merged commit b8c7327 into main Aug 29, 2026
3 checks passed
@blurbery
blurbery deleted the hotfix/postgres-search-parameter-types branch August 29, 2026 05:33
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