Skip to content

Fix effective_mappings field to remove _doc wrapper#4

Open
augment-app-staging[bot] wants to merge 1 commit intomainfrom
eval-61c5c7bf
Open

Fix effective_mappings field to remove _doc wrapper#4
augment-app-staging[bot] wants to merge 1 commit intomainfrom
eval-61c5c7bf

Conversation

@augment-app-staging
Copy link

Summary

This PR fixes the effective_mappings field in the get data stream API response which was incorrectly including a _doc wrapper at the top level.

Problem

The effective_mappings field in the following API responses was wrapped in a _doc object:

  • GET /_data_stream/{name}/_mappings (get data stream mappings)
  • PUT /_data_stream/{name}/_mappings (update data stream mappings)

According to the API specification, effective_mappings should contain the mapping content directly (e.g., {"properties": {...}, "_data_stream_timestamp": {...}}) without being wrapped in {"_doc": {"properties": {...}, ...}}.

Solution

The fix strips the _doc wrapper when serializing effective_mappings in the toXContent methods of:

  • GetDataStreamMappingsAction.DataStreamMappingsResponse
  • UpdateDataStreamMappingsAction.DataStreamMappingsResponse

The logic checks if the uncompressed effective mappings map contains exactly one key named _doc, and if so, unwraps it before serializing.

Changes

  1. Modified GetDataStreamMappingsAction.java: Added logic to strip the _doc wrapper from effective_mappings in the toXContent method.

  2. Modified UpdateDataStreamMappingsAction.java: Added the same logic to strip the _doc wrapper from effective_mappings in the toXContent method.

  3. Updated test file 250_data_stream_mappings.yml: Changed all test assertions from effective_mappings._doc.properties to effective_mappings.properties to match the corrected output format.

Testing

All existing YAML REST tests in modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/250_data_stream_mappings.yml have been updated and pass successfully.

Related

Note: This PR was not assigned to anyone as it was triggered by an automated evaluation bot.

The effective_mappings field in the get data stream API response
(GET /_data_stream/{name}/_mappings) and update data stream mappings
API response (PUT /_data_stream/{name}/_mappings) was incorrectly
including a _doc wrapper at the top level.

According to the API specification, effective_mappings should contain
the mapping content directly (e.g., {\properties\: {...}}) without
being wrapped in {\_doc\: {\properties\: {...}}}.

This fix strips the _doc wrapper when serializing effective_mappings
in the toXContent methods of:
- GetDataStreamMappingsAction.DataStreamMappingsResponse
- UpdateDataStreamMappingsAction.DataStreamMappingsResponse

Updated tests to expect the correct format without the _doc wrapper.

Fixes: https://augment-wic8570.slack.com/archives/C0AG2MXKEQJ/p1772152880428979
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.

0 participants