Repository navigation
Fixes #31878: return 400 for a search against an index OpenMetadata does not manage - #35516
Conversation
| * <p>A missing index ({@code 404}) depends on whose name it is. A name OpenMetadata does not manage | ||
| * is the caller's mistake and is a 400. A managed index that is missing from the cluster, for | ||
| * example after a failed reindex, is an outage and stays a 500. Issue #31878. |
There was a problem hiding this comment.
⚠️ Quality: New 400-vs-500 index-not-found contract has no decision record
This PR adds a REST error contract that clients and Collate both have to follow. /search/query and /search/get/{index}/doc/{id} now return 400 Unknown search index [<name as typed>] for a name OpenMetadata does not manage. A managed index that is missing from the cluster still returns 500 Failed to find index .... Nothing in docs/decisions/ records this rule.
The Javadoc in SearchEngineErrors covers the 400/500 split. It leaves out the parts of the rule that only appear in the PR description:
- "Managed" covers Collate's indexes because they are "merged into the same registry". Collate has to keep registering its indexes there, or its own missing indexes will start returning 400 and stop alerting.
- "Nothing is checked before the request reaches the engine, so no request that works today can start failing." This explains why the check is not done up front.
getDocByIDkeeps 404Document not found.for a missing document, and a missing index there now follows the 400/500 split.
The repo squash-merges, so the description will not reach git log.
The record would say: "A search engine 404 for a missing index is reported as 400 Unknown search index [...] when any name in the expression is not an entity type, canonical index name or alias in the index-mapping registry (OSS plus Collate). Otherwise it stays a 500, because a missing managed index is an outage. Wildcards, exclusions and Data Insights names never count as unknown. Names are classified only after the engine has answered, never before the request is sent."
Add a record and cite it from the classifier.:
// docs/decisions/2026-10-<dd>-an-unknown-search-index-is-a-400-and-a-missing-managed-index-a-500.md
// and in SearchEngineErrors Javadoc:
* ADR:2026-10-<dd>-an-unknown-search-index-is-a-400-and-a-missing-managed-index-a-500
Was this helpful? React with 👍 / 👎
Code Review
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
|



Fixes #31878
Problem
A search against an index name OpenMetadata does not have, such as
GET /api/v1/search/query?index=nope_search_index, returns 500Failed to find index nope_search_index. Nothing on the server failed: the caller asked for a name that does not exist. A 500 is logged at ERROR, so a typo in an API client or script shows up as a backend fault in error tracking and in the 5xx rate.The other cases in #31878 (malformed query text, an out-of-range page) were fixed by PR #33655, which reports the engine's 400 as a 400. A missing index is different: the engine answers 404, and the search managers turn every 404 into
SearchIndexNotFoundException, which defaults to 500.Why not always 400
The same 404 also happens when one of OpenMetadata's own indexes is missing from the cluster, for example an alias left detached by a failed reindex (
DefaultRecreateHandlerdocuments this case). That is a real outage and must keep alerting, so it stays a 500.What this PR changes
When the engine says an index is missing, OpenMetadata now checks whose name it was:
Unknown search index [nope_search_index]. The name is reported as the caller typed it, without the cluster prefix.Failed to find index ..., with the same text as today."Managed" means any entity type, canonical index name or alias in the index mapping registry. That includes Collate's indexes, which are merged into the same registry. Wildcards and Data Insights names never count as unknown. The set of known names is built once when the mappings load. Nothing is checked before the request reaches the engine, so no request that works today can start failing.
The rule lives in one place,
SearchEngineErrors.indexNotFound, and all 10 places that turned a 404 into a 500 now call it. That coversdoSearch,searchForExport,doListWithOffsetandlistWithDeepPaginationin both search managers, andgetDocByIDin both entity managers.getDocByID(GET /v1/search/get/{index}/doc/{id}) also stops sayingFailed to find doc with id ...for a missing index. A missing document never reached that branch: it already returns 404Document not found., which this PR keeps.How it was tested
SearchIndexUtilsTest: which names count as known, and a table of typed index expressions with and without a cluster alias (table,all,dataAsset,nope_search_index,table,nope,nope*,di-data-assets-table, a prefixed name, an empty registry).SearchEngineErrorsTest: an unknown name gives 400 with the exact message, and a managed index gives 500 with the exact message.SearchResourceIT:index=nope_search_index,index=table_search_index,nope_search_indexand/search/get/nope_search_index/doc/...return 400, and a missing document in a real index still returns 404. These pass on Elasticsearch and OpenSearch, together with the existing malformed-input tests (12 of 12 on each engine).SearchRepositoryBehaviorTest,SearchSourceBuilderFactoryTest,LuceneQuerySyntaxTestand others, 384 tests).A managed index that is missing from the cluster is covered by the unit test only: deleting a shared index in the integration test cluster is not safe.
Not in this PR
/search/fieldQueryand/search/aggregatereach the engine through other code and still report an unknown index as a 500.FAILED_TO_FIND_INDEX_ERRORconstant has a typo (Failed to to find index), so the index-not-found banner never matches.