Skip to content

Throw exception for unsupported values type in Alias#124737

Merged
elasticsearchmachine merged 9 commits intoelastic:mainfrom
mushao999:optimize/alias
Apr 28, 2025
Merged

Throw exception for unsupported values type in Alias#124737
elasticsearchmachine merged 9 commits intoelastic:mainfrom
mushao999:optimize/alias

Conversation

@mushao999
Copy link
Contributor

After creating index with alias using the following request

PUT test-index
{
  "aliases": {
    "alias1": {
      "is_write_index": "true"
    }
  }
}

we got the following result for get index request:

{
  "test-index" : {
    "aliases" : {
      "alias1" : { }
    },
    "mappings" : { },
    "settings" : {   
      ...
    }
  }
}

The is_write_index field is missing because string boolean value is not supported for this filed and no warning message showed, which will mislead the users.
In #120453 I open a PR to let the createIndex API support string boolean values for is_write_index field, but @dakrone think it's better to be strict about boolean values.
So I open this PR to let the Alias class throw exception for the unsupport value type to avoid the slience swallowing of this case.

@elasticsearchmachine elasticsearchmachine added needs:triage Requires assignment of a team area label external-contributor Pull request authored by a developer outside the Elasticsearch team v9.1.0 labels Mar 13, 2025
@dakrone dakrone added the :Data Management/Indices APIs DO NOT USE. Use ":Distributed/Indices APIs" or ":StorageEngine/Templates" instead. label Mar 13, 2025
@elasticsearchmachine elasticsearchmachine added Team:Data Management (obsolete) DO NOT USE. This team no longer exists. and removed needs:triage Requires assignment of a team area label labels Mar 13, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@mushao999
Copy link
Contributor Author

ping @dakrone

@dakrone dakrone self-assigned this Mar 20, 2025
Copy link
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

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

Thanks for opening this @mushao999, it looks pretty good. Would you mind adding a test for this to …/indices.put_alias/10_basic.yml that ensures that a bad request is returned? That way we don't accidentally undo this in the future without checking it.

@dakrone
Copy link
Member

dakrone commented Mar 21, 2025

buildkite test this

@dakrone dakrone added the >bug label Mar 21, 2025
@mushao999
Copy link
Contributor Author

Thanks for opening this @mushao999, it looks pretty good. Would you mind adding a test for this to …/indices.put_alias/10_basic.yml that ensures that a bad request is returned? That way we don't accidentally undo this in the future without checking it.

yamlRestTest case added @dakrone

@mushao999
Copy link
Contributor Author

Please also review this one , thanks @dakrone

@dakrone
Copy link
Member

dakrone commented Apr 10, 2025

buildkite test this

Copy link
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@dakrone dakrone added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Apr 10, 2025
@mushao999
Copy link
Contributor Author

@dakrone Cluster feature was added for BWC tests, please also enable the auto-testing for this one, thanks.

@dakrone
Copy link
Member

dakrone commented Apr 28, 2025

buildkite test this

@elasticsearchmachine elasticsearchmachine merged commit 637807c into elastic:main Apr 28, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >bug :Data Management/Indices APIs DO NOT USE. Use ":Distributed/Indices APIs" or ":StorageEngine/Templates" instead. external-contributor Pull request authored by a developer outside the Elasticsearch team Team:Data Management (obsolete) DO NOT USE. This team no longer exists. v9.1.0

3 participants