fix(api): GET /{index} 404s on an alias name instead of resolving it - #49
Closed
Vinz2168 wants to merge 1 commit into
Closed
fix(api): GET /{index} 404s on an alias name instead of resolving it#49Vinz2168 wants to merge 1 commit into
Vinz2168 wants to merge 1 commit into
Conversation
Every other index-scoped endpoint (_search, _update, _alias, HEAD
/{index}) resolves an alias to its backing physical index before
acting -- get_index_inner was the one place that shortcut this by
checking literal membership in the physical index list first, so an
alias name always fell into the "missing" branch and 404'd before
alias resolution ever got a chance to run.
This broke Kibana's own startup migration check: Kibana calls
GET /.kibana at boot to see whether a prior migration already
created and aliased .kibana_1. With this bug xerj always reported
.kibana as missing, so Kibana concluded no migration had happened,
tried to freshly CREATE .kibana_1, collided with the physically
existing index, and got stuck forever on "Another Kibana instance
appears to be migrating the index" -- recurring across this session
and only ever worked around operationally by deleting .kibana_1 and
letting Kibana re-migrate from scratch.
Fix: resolve each exact-name selector segment through
engine.resolve_alias() before checking it against the physical index
list, mirroring the pre-expansion pattern _search/_update/_field_caps
already use. The resolved physical name is what's returned (matching
real ES, which keys a Get Index API response by the concrete backing
index, not the alias) and matches what GET /_alias/{name} in this
codebase already reports.
Verified: GET /{alias} now returns 200 keyed by the backing index
instead of 404. Full ES-compat YAML conformance suite: 1360 passed,
0 failed, 3 skipped -- no regressions.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016XJaZygeuRfZfUg2B8tPKU
Collaborator
Author
|
Duplicate of #30, opened earlier in the same session before a context compaction lost track of it. #30 is a superset of this fix — it also resolves aliases in the shared |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /{index}(the Get Index API — returns aliases + mappings + settings) 404s when{index}is an alias name instead of resolving it to its backing physical index. Every other index-scoped endpoint (_search,_update,_alias,HEAD /{index}) resolves aliases correctly — this handler was the one place that shortcut alias resolution.Real-world impact
This broke Kibana's own startup migration check. Kibana calls
GET /.kibanaat boot to see whether a prior migration already created and aliased.kibana_1. With this bug, xerj always reported.kibanaas missing (even though.kibana_1existed and the alias was correctly set — confirmed viaGET /_alias/.kibana,GET /.kibana/_search, andPOST /.kibana/_update/..., all of which worked fine). Kibana concluded no migration had happened, tried to freshlyCREATE .kibana_1, collided with the physically existing index, and got stuck forever on"Another Kibana instance appears to be migrating the index. Waiting for that migration to complete."— the only workaround was deleting.kibana_1entirely and letting Kibana re-migrate from scratch.Root cause
get_index_inner's exact-name resolution checked literal membership in the physical index list (all.iter().any(|info| info.name == part)) before ever consulting alias metadata, so an alias name always fell into the "missing" branch and returned 404 immediately — alias resolution never got a chance to run. Every other handler in the codebase either callsengine.get_index()(which is alias-aware internally) or pre-expands the selector throughengine.resolve_alias()before touching the physical index list.Fix
Resolve each exact-name selector segment through
engine.resolve_alias()before checking it against the physical index list, mirroring the pre-expansion pattern_search/_update/_field_capsalready use. The resolved physical name is what's returned in the response — matching real Elasticsearch, which keys a Get Index API response by the concrete backing index rather than the alias, and matching whatGET /_alias/{name}in this codebase already reports.Test plan
cargo build --release -p xerj-api -p xerj-engine -p xerj-servercargo fmt --check/cargo clippy --no-deps -- -D warnings— cleanGET /{alias}now returns 200 keyed by the backing index (was 404 before the fix)🤖 Generated with Claude Code