Skip to content

Fix 500 on PPL query over alias spanning mapping-less index - #22665

Open
alchemist51 wants to merge 1 commit into
opensearch-project:mainfrom
alchemist51:fix-mapping-issue
Open

Fix 500 on PPL query over alias spanning mapping-less index#22665
alchemist51 wants to merge 1 commit into
opensearch-project:mainfrom
alchemist51:fix-mapping-issue

Conversation

@alchemist51

Copy link
Copy Markdown
Contributor

Description

An alias (or index pattern) spanning an index that was created empty and never written to — so it has no mapping — alongside a populated index caused analytics-engine PPL queries to fail with a 500:

source=my_alias | stats count()
→ 500 RuntimeException: internal problem at backend

The same query on a GENERAL-mode domain returns the populated index's count.

Root cause: three components in the analytics planning path read index mappings. OpenSearchSchemaBuilder and IndexResolution.validateSchemaCompatibility already skip a null mapping, but FieldStorageResolver threw IllegalStateException("No mapping found for index") when CapabilityRegistry.resolveFieldStorage(List)'s per-index loop reached the mapping-less backing index.

Fix: FieldStorageResolver now treats a null mapping / missing properties as an empty field set. The empty index contributes nothing to the merged field-storage union, matching the rest of the pipeline. A query targeting only mapping-less indices still fails cleanly upstream at Calcite validation with "table not found" (the schema builder yields no row type), so that error path is unchanged.

Testing:

  • Unit: FieldStorageResolverTests#testIndexWithoutMappingContributesNoFields, #testMergedResolverSkipsMappinglessIndex
  • Integration: AliasIT#testAliasSpansMappinglessEmptyIndex — creates the exact alias shape (empty index with no mappings + populated index) and asserts stats count() returns the populated index's doc count
  • Verified end-to-end on version-matched 3.5 test domains: GENERAL returned 3, OPTIMIZED returned 500 before this fix

Related Issues

N/A

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

An alias (or index pattern) spanning an index that was created empty
and never written to — so it has no mapping — alongside a populated
index caused analytics-engine PPL queries to fail with a 500.

FieldStorageResolver threw IllegalStateException ("No mapping found
for index") when the per-index resolution loop reached the
mapping-less index. The schema builder and IndexResolution already
skip such indices, so the resolver was the lone component treating
them as an error.

Treat a null mapping / missing properties as an empty field set
instead: the index contributes nothing to the field-storage union,
matching how the rest of the pipeline (and the GENERAL engine mode)
handles it. A query targeting only mapping-less indices still fails
cleanly upstream at Calcite validation with "table not found".

Adds unit tests for the empty resolver and the merged union, plus an
integration test reproducing the alias shape end-to-end.

Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
@alchemist51
alchemist51 requested a review from a team as a code owner August 6, 2026 17:41

@mch2 mch2 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.

thanks @alchemist51

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.

2 participants