Skip to content

Fetching _seq_no via fields results in 5xx error #107136

@salvatore-campagna

Description

@salvatore-campagna

Elasticsearch Version

main

Installed Plugins

No response

Java Version

bundled

OS Version

all

Problem Description

I discovered this while working on #106325.

Executing the following yaml test succeeds, which means requesting _seq_no via fields returns a 5xx error.

---
fetch _seq_no via fields:

  - do:
      catch: "request"
      search:
        index: test
        body:
          fields: [ _seq_no ]

  # This should be `unauthorized` (401) or `forbidden` (403) or at least `bad request` (400)
  # while instead it is mapped to an `internal_server_error (500)`
  - match: { status: 500 }
  - match: { error.root_cause.0.type: unsupported_operation_exception }
  - match: { error.root_cause.0.reason: "Cannot fetch values for internal field [_seq_no]." }

This happens because in the fetch phase (FetchFieldsPhase) we try to use the SeqNoFieldMapper ValueFetcher which throws an UnsupportedOperationException. I think this is the case for other metadata fields too...all those throwing such exception.

Notice that the same issue does not happen if we request _seq_no via stored_fields because StoredFieldPhase does not use ValueFetcher to retrieve field values.

Steps to Reproduce

Just execute the yaml test against main

Logs (if relevant)

No response

Metadata

Metadata

Assignees

Labels

:Search Foundations/SearchCatch all for Search Foundations>bugTeam:Search FoundationsMeta label for the Search Foundations team in Elasticsearchpriority:normalA label for assessing bug priority to be used by ES engineers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions