Skip to content

Add Boolean#parseBoolean to forbidden-apis #59190

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

Open
jaymode opened this issue Jul 7, 2020 · 8 comments
Open

Add Boolean#parseBoolean to forbidden-apis #59190

jaymode opened this issue Jul 7, 2020 · 8 comments
Labels
:Core/Infra/Core Core issues without another label good first issue low hanging fruit Team:Core/Infra Meta label for core/infra team triaged Issue has been looked at, and is being left open

Comments

@jaymode
Copy link
Member

jaymode commented Jul 7, 2020

In #22200, existing boolean parsing was made strict so that:

"true" is converted to the boolean value true, "false" is converted to the boolean value false. Everything else raises an error.

However, usages of Boolean.parseBoolean have made their way into the codebase since then and the implementation of the JDKs boolean parsing logic is anything but strict as a string that is a case-insensitive match to true will be true and everything else will be false.

I think we should remove these usages of Boolean.parseBoolean after deprecation in the places where it was previously used and add this API to our forbidden-apis list.

@jaymode jaymode added :Core/Infra/Core Core issues without another label team-discuss labels Jul 7, 2020
@elasticmachine
Copy link
Collaborator

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

@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Jul 7, 2020
@rjernst
Copy link
Member

rjernst commented Jul 7, 2020

It is unfortunate we let this lapse; a lot of work went into removing uses of lenient boolean parsing. It looks like most of the uses added are in tests, although there appear to be a couple that are user facing. +1 to adding the method to forbidden apis to stop the bleeding.

@rjernst rjernst added the needs:triage Requires assignment of a team area label label Dec 3, 2020
@pgomulka pgomulka removed the needs:triage Requires assignment of a team area label label Dec 10, 2020
@mosche mosche added good first issue low hanging fruit triaged Issue has been looked at, and is being left open labels Mar 14, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@esousacosta
Copy link
Contributor

esousacosta commented Apr 9, 2025

Hi,

I'm willing to contribute by working on this. Is that ok?

I started looking into the places we need the Boolean.parseBoolean replaced.

@mosche
Copy link
Contributor

mosche commented Apr 14, 2025

Thanks @esousacosta , your contribution would be much appreciated.
Note, for backwards compatibility we'll likely want to deprecate the old behavior first, meaning every other value than true or false should log a deprecation warning rather than throwing an error. I'll discuss and confirm that with the team.

@esousacosta
Copy link
Contributor

No problem, @mosche.

Thank you for letting me know about the deprecation warning. I'll be on lookout here for more news on this matter, then.

@mosche
Copy link
Contributor

mosche commented Apr 14, 2025

@esousacosta a decent first step here could be to:

  • add Boolean#parseBoolean to the forbidden apis
  • replace all usage in tests (and potentially other cases if there's no backwards compatibility concerns) with org.elasticsearch.core.Booleans#parseBoolean
  • add @SuppressForbidden to remaining public facing usage (e.g. for settings or surfacing) with a TODO to add a deprecation warning for any usage of invalid values that would break once migrating to Booleans#parseBoolean + a link to this issue.

Deprecation warnings are a bit more involved, we could discuss these in a follow up. Wdyt?

@esousacosta
Copy link
Contributor

esousacosta commented Apr 14, 2025

Looks good to me as a plan, @mosche.

I'll start on that and update the issue when I have news 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label good first issue low hanging fruit Team:Core/Infra Meta label for core/infra team triaged Issue has been looked at, and is being left open
Projects
None yet
Development

No branches or pull requests

7 participants