Skip to content

Remove Alias must_exist field is unknown #62642

Closed
@aaron-nimocks

Description

@aaron-nimocks

Elasticsearch version : 7.9

Description of the problem including expected versus actual behavior:

The PR for this feature.

When adding a must_exist field to a remove index alias API call it does not recognize the field. Also does not show up in autocomplete in Kibana.

Initially reported - https://discuss.elastic.co/t/must-exist/249009

Steps to reproduce:

POST /_aliases
{
  "actions": [
    {
      "remove": {
        "index": "doesntmatter",
        "alias": "aliasname",
        "must_exist": true
      }
    }
  ]
}

Returns Error

{
  "error" : {
    "root_cause" : [
      {
        "type" : "x_content_parse_exception",
        "reason" : "[7:9] [remove] unknown field [must_exist]"
      }
    ],
    "type" : "x_content_parse_exception",
    "reason" : "[7:23] [aliases] failed to parse field [actions]",
    "caused_by" : {
      "type" : "x_content_parse_exception",
      "reason" : "[7:23] [alias_action] failed to parse field [remove]",
      "caused_by" : {
        "type" : "x_content_parse_exception",
        "reason" : "[7:9] [remove] unknown field [must_exist]"
      }
    }
  },
  "status" : 400
}

Verified the field is present
https://github.com/elastic/elasticsearch/blob/7.9/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java#L101

Verified the error handing works if you change type to add
https://github.com/elastic/elasticsearch/blob/7.9/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java#L477

Possible reason is that the field is not in XContentBuilder
https://github.com/elastic/elasticsearch/blob/7.9/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java#L521

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions