Skip to content

more consistent allow_no_indices=false errors#142373

Merged
richard-dennehy merged 11 commits intoelastic:mainfrom
richard-dennehy:cps-more-consistent-allow-no-indices
Feb 24, 2026
Merged

more consistent allow_no_indices=false errors#142373
richard-dennehy merged 11 commits intoelastic:mainfrom
richard-dennehy:cps-more-consistent-allow-no-indices

Conversation

@richard-dennehy
Copy link
Copy Markdown
Contributor

@richard-dennehy richard-dennehy commented Feb 12, 2026

Resolving certain index expressions returns an empty list of indices, even when allow_no_indices=false; this PR adds extra validation to fix some of these, e.g. -logs*, concrete-index-1,-concrete-index-1

@richard-dennehy richard-dennehy added >non-issue :Security/Security Security issues without another label labels Feb 12, 2026
@elasticsearchmachine elasticsearchmachine added the serverless-linked Added by automation, don't add manually label Feb 12, 2026
remote
);
assertNotNull(ex);
assertThat(ex.getMessage(), equalTo("no such index []"));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do we want a better error message than this? I'm not sure what it could say, though 🤔

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.

I think we can report whatever the original expresssions are, e.g. no such index [-logs*], etc. This is not very different from resolution for something like no-match-*.

Comment on lines +247 to +250
if (localResolvedExpressions.localIndicesIsEmpty()
&& remoteResolvedExpressions.values().stream().allMatch(ResolvedIndexExpressions::localIndicesIsEmpty)) {
return new IndexNotFoundException("");
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not delighted with what's effectively "loop over the entire list of local expressions and also loop over all the remote expressions again", but it seems difficult to incorporate this logic into the existing loop.

Tbh I'm starting to get concerned that validate is becoming too complicated to reason about - I'm having a very hard time following the logic without using a debugger

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.

Yeah I raised ES-13804 a while back to improve the validator. The most relevant is the 2nd point from the Jira issue, which suggests extracting the logic into a per-validation class. I think it's a good candidate to work on after fixing the existing two bugs.

@richard-dennehy richard-dennehy marked this pull request as ready for review February 13, 2026 17:04
@elasticsearchmachine elasticsearchmachine added the Team:Security Meta label for security team label Feb 13, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-security (Team:Security)

Copy link
Copy Markdown
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

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

LGTM

if (notFoundException == null && indicesOptions.allowNoIndices() == false) {
if (localResolvedExpressions.localIndicesIsEmpty()
&& remoteResolvedExpressions.values().stream().allMatch(ResolvedIndexExpressions::localIndicesIsEmpty)) {
return new IndexNotFoundException(localResolvedExpressions.expressions().getFirst().original());
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.

I think we may want to concate all local original expressions to a single string for the report, similar to how it is done here in IndicesAndAliasesResolver.

@richard-dennehy richard-dennehy merged commit fb9b698 into elastic:main Feb 24, 2026
41 checks passed
szybia added a commit to szybia/elasticsearch that referenced this pull request Feb 24, 2026
…on-sliced-reindex

* upstream/main:
  Mute org.elasticsearch.reindex.management.ReindexManagementClientYamlTestSuiteIT test {yaml=reindex/30_cancel_reindex/Cancel running reindex returns response and GET confirms completed} elastic#142079
  [ESQL] Fix async logging consistency and severity (elastic#142401)
  more consistent allow_no_indices=false errors (elastic#142373)
  Attribute ES|QL shard search load in Lucene operators (elastic#142841)
  MetricsInfoOperator refactoring (elastic#142935)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>non-issue :Security/Security Security issues without another label serverless-linked Added by automation, don't add manually Team:Security Meta label for security team v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants