Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORE: Validate list values for settings #71276

Closed
wants to merge 3 commits into from
Closed

CORE: Validate list values for settings #71276

wants to merge 3 commits into from

Conversation

amitds1997
Copy link

@amitds1997 amitds1997 commented Apr 4, 2021

Settings value could be a list. This should only
happen if the underlying setting type is a list setting type.

  • Validation has been added that
    • when we get a setting value which is list, setting
      is also a list setting
    • when we get a value for a list setting, underlying
      value is also a list
  • Closes String settings leniently accept lists #33135

Settings value could be a list. This should only
happen if the underlying setting type is a list setting type.

* Validation has been added that
	* when we get a setting value which is list, setting
is also a list setting
	* when we get a value for a list setting, underlying
 value is also a list
* Closes #33135
@elasticsearchmachine elasticsearchmachine added the external-contributor Pull request authored by a developer outside the Elasticsearch team label Apr 4, 2021
@jtibshirani jtibshirani added the :Core/Infra/Settings Settings infrastructure and APIs label Apr 22, 2021
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Apr 22, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@pgomulka pgomulka self-requested a review May 11, 2021 07:07
@pgomulka
Copy link
Contributor

ok to test

@pgomulka
Copy link
Contributor

@elasticmachine update branch

Copy link
Contributor

@pgomulka pgomulka left a comment

Choose a reason for hiding this comment

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

looks good, thanks!
can you add the testcase for happy path and fix the failing test?
You might need to change the exception message and remove the if condition that throws Environment

 String rawDataPath = PATH_DATA_SETTING.get(settings);
            if (rawDataPath.startsWith("[")) {

IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> stringSetting.get(settings));
assertEquals("Found list type value for setting [foo.bar] but did not expect a list for it.", e.getMessage());
}

public void testGetAsArrayFailsOnDuplicates() {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we also have a happy path testcase where Setting.listSetting parses successfully ?

@rjernst
Copy link
Member

rjernst commented Aug 12, 2021

@amitds1997 Are you still interested in getting this PR in? If so can you please address the comments Przemek made above?

@rjernst rjernst self-assigned this Aug 12, 2021
@amitds1997
Copy link
Author

Sorry, I won't be able to get this through. Anyone else can take this up. Thanks!

@amitds1997 amitds1997 closed this Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Settings Settings infrastructure and APIs external-contributor Pull request authored by a developer outside the Elasticsearch team Team:Core/Infra Meta label for core/infra team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

String settings leniently accept lists
6 participants