Skip to content

Fix effective_mappings field to remove _doc wrapper#6

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

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

Conversation

@augment-app-staging
Copy link

Summary

This PR fixes the effective_mappings field in the get data stream mappings API and update data stream mappings API to remove the incorrect _doc wrapper.

Problem

The effective_mappings field returned by the get data stream mappings API (GetDataStreamMappingsAction) and update data stream mappings API (UpdateDataStreamMappingsAction) contained a _doc type wrapper that shouldn't be present according to the spec.

Before:

{
  "effective_mappings": {
    "_doc": {
      "properties": { ... }
    }
  }
}

After:

{
  "effective_mappings": {
    "properties": { ... }
  }
}

Solution

Added logic to strip the _doc wrapper from effective_mappings in the toXContent methods of both:

  • GetDataStreamMappingsAction.DataStreamMappingsResponse
  • UpdateDataStreamMappingsAction.DataStreamMappingsResponse

This follows the same pattern used in MappingMetadata.sourceAsMap() which strips the type wrapper when converting mappings to a map.

Changes

  1. GetDataStreamMappingsAction.java: Added check to strip _doc wrapper from effective_mappings before serializing to XContent
  2. UpdateDataStreamMappingsAction.java: Added check to strip _doc wrapper from effective_mappings before serializing to XContent
  3. 250_data_stream_mappings.yml: Updated YAML rest tests to expect effective_mappings.properties instead of effective_mappings._doc.properties

Testing

  • Updated YAML rest tests in 250_data_stream_mappings.yml
  • Existing Java unit tests (GetDataStreamMappingsActionTests and UpdateDataStreamMappingsActionResponseTests) already expect the correct format without the _doc wrapper

Related

Note: This PR was automatically created by Augment Agent. Please review carefully before merging.

The effective_mappings field in the get data stream mappings API
(GetDataStreamMappingsAction) and update data stream mappings API
(UpdateDataStreamMappingsAction) was incorrectly returning a _doc
type wrapper that shouldn't be present according to the spec.

This change strips the _doc wrapper from effective_mappings before
returning it to the client, similar to how MappingMetadata.sourceAsMap()
handles the type wrapper.

Changes:
- Modified GetDataStreamMappingsAction.DataStreamMappingsResponse.toXContent
  to strip _doc wrapper from effective_mappings
- Modified UpdateDataStreamMappingsAction.DataStreamMappingsResponse.toXContent
  to strip _doc wrapper from effective_mappings
- Updated YAML rest tests to expect effective_mappings without _doc wrapper

The response now correctly returns:
{
  "effective_mappings": {
    "properties": { ... }
  }
}

Instead of:
{
  "effective_mappings": {
    "_doc": {
      "properties": { ... }
    }
  }
}

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