Skip to content

Throw a typed, retryable error when querying an attribute whose index is still building - #1363

Merged
kriszyp merged 2 commits into
mainfrom
1355-typed-index-rebuilding-error
Jun 18, 2026
Merged

kriszyp merged 2 commits into
mainfrom
1355-typed-index-rebuilding-error

Conversation

@heskew

@heskew heskew commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

A query on an attribute whose secondary index is still (re)building threw a generic 503 (ServerError), indistinguishable from a permanent failure — so callers that wrap per-row lookups in try/catch (e.g. a dedup-before-insert import) could silently treat it as a "no result" and drop writes for the duration of the rebuild.

Adds IndexRebuildingError (extends ServerError; statusCode 503, code: INDEX_REBUILDING, retryable: true), thrown from the search isIndexing path (message unchanged for back-compat). In-process callers can now branch on instanceof / code / retryable; the operations-API error body also carries code/retryable (gated on error.retryable, so other errors are unaffected). The REST/http.ts path already distinguishes it via the class name in the body.

Resolves #1355 (part of #1354).

Where to look

  • server/serverHelpers/serverHandlers.js — the only behavioral change on the operations-API path: the 503 body now includes code/retryable when error.retryable is set. Adding fields is additive, but worth a glance if any strict downstream client/proxy depends on the exact { error } shape.
  • utility/errors/hdbError.ts — the new error class.

Docs

Introduces a new public error code (INDEX_REBUILDING). Minor — flagging the docs decision rather than assuming: happy to add a short mention to the operations-API error docs if wanted (not done in this PR).


🤖 Generated with Claude Code (Opus 4.8)

…ebuild

A query on an attribute whose secondary index is still building threw a generic
503 (ServerError), indistinguishable from a permanent failure. Callers that wrap
per-row lookups in try/catch (e.g. a dedup-before-insert import) could silently
treat it as "no result" and drop writes for the duration of the rebuild.

Introduce IndexRebuildingError (extends ServerError; statusCode 503,
code INDEX_REBUILDING, retryable true), thrown from the search isIndexing path
(message unchanged for back-compat). Surface code/retryable in the operations-API
error body, gated on error.retryable so other errors are unaffected, so HTTP
callers can distinguish and retry as well as in-process callers.

Closes #1355

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@heskew
heskew requested review from cb1kenobi and kriszyp June 18, 2026 00:09

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new IndexRebuildingError class (extending ServerError) to handle queries on attributes with rebuilding secondary indexes as a distinct, retryable 503 error. It updates the search logic, error handler, and unit tests to support and verify this behavior. The review feedback suggests setting the name property on the new error class to ensure correct serialization and stack traces, along with adding a corresponding assertion in the unit tests.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread utility/errors/hdbError.ts
Comment thread unitTests/utility/errors/hdbError.test.js
@claude

claude Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed; no blockers found.

@heskew
heskew marked this pull request as ready for review June 18, 2026 04:34
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

ServerError/Error leave `name` as 'Error', so without this the stack trace,
JSON serialization, and any caller keying on error.name would not identify
the error. Set it explicitly and assert it in the unit test. (review feedback)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@kriszyp kriszyp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, minimal typed error — correct placement on the cold indexing path. LGTM! 🟢

Reviewed by Claude Sonnet 4.6

@kriszyp
kriszyp merged commit cbdc28a into main Jun 18, 2026
53 of 54 checks passed
@kriszyp
kriszyp deleted the 1355-typed-index-rebuilding-error branch June 18, 2026 17:28
@heskew

heskew commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Docs follow-up: HarperFast/documentation#532 documents the new INDEX_REBUILDING retryable 503 (kept as a draft pending version-badge finalization once this ships in a release). (AI-generated, Claude Opus 4.8.)

kriszyp pushed a commit to HarperFast/documentation that referenced this pull request Jun 18, 2026
* docs(query-optimization): document the INDEX_REBUILDING retryable 503

Querying an attribute whose secondary index is still (re)building now returns a
typed, retryable 503 (code INDEX_REBUILDING). Documents the response shape and
the retry guidance in the Query Optimization reference. See HarperFast/harper#1363.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* docs(query-optimization): format INDEX_REBUILDING error fields as a table

Per review feedback (matches the operator table earlier in this doc). Values
backticked so the message's <attribute> placeholder isn't parsed as JSX in MDX.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.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.

Throw a typed, retryable error when querying an attribute whose index is still building

2 participants