You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "tflobbe (via GitHub)" <gi...@apache.org> on 2023/09/15 23:40:28 UTC
[GitHub] [solr] tflobbe opened a new pull request, #1931: SOLR-16978: Be case insensitive when parsing booleans from text
tflobbe opened a new pull request, #1931:
URL: https://github.com/apache/solr/pull/1931
The translation between V1 parameters into the new code based in V2 APIs is using `StrUtils.getBool(String param)` to parse from string. This `StrUtils.getBool` is intended to be more flexible than `Boolean.parseBoolean()`, and accepts things like `yes`/`no`, `on`/`off`, but it's case sensitive.
This PR makes it case insensitive. Note that this code is often used for reading configuration files, so those will also now be case insensitive when this is merged.
An alternative could be to have a new method to be case insensitive and use that one for the API parameters, but really, if this code is supposed to be more flexible than `Boolean.parseBoolean()`, I think make it case insensitive is the right way to go.
I was also a bit surprised that this code uses `startsWith`, for the most part, which sounds strange to me (maybe intended to allow trailing whitespaces? I'm not sure), but that could be a discussion for a different PR (changing that would be a breaking change)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] tflobbe merged pull request #1931: SOLR-16978: Be case insensitive when parsing booleans from text
Posted by "tflobbe (via GitHub)" <gi...@apache.org>.
tflobbe merged PR #1931:
URL: https://github.com/apache/solr/pull/1931
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [GitHub] [solr] tflobbe commented on pull request #1931: SOLR-16978: Be case insensitive when parsing booleans from text
Posted by Eric Pugh <ep...@apache.org>.
I wonder if we should strive to be consistent (in either lenient mode or strict mode) through out Solr? For example, I noticed that the AuthTool does a check for "true" or "false" with some custom code. If we said that on, off, etc are all valid choices, then we could support that through out? Instead of some places have one set of rules, and others something different.
private void ensureArgumentIsValidBooleanIfPresent(CommandLine cli, String argName) {
if (cli.hasOption(argName)) {
final String value = cli.getOptionValue(argName);
if (!"true".equalsIgnoreCase(value) && !"false".equalsIgnoreCase(value)) {
echo("Argument [" + argName + "] must be either true or false, but was [" + value + "]");
SolrCLI.exit(1);
}
}
}
On 2023/09/18 23:50:36 "tflobbe (via GitHub)" wrote:
>
> tflobbe commented on PR #1931:
> URL: https://github.com/apache/solr/pull/1931#issuecomment-1724631857
>
> @gerlowskija Any thoughts here? I'm on the fence. I don't really love the leniency with which we are reading boolean params here, it seems more useful for configuration files than it is for request parameters, but that's what other parts of the code are using, so I also want to consider consistency with other APIs.
> As far as I can tell, pre-Solr9 most Collections API parameters `ZkNodeProps`, which uses `Boolean.getBoolean` (case insensitive), so that's why they worked before and not now.
>
>
> --
> This is an automated message from the Apache Git Service.
> To respond to the message, please log on to GitHub and use the
> URL above to go to the specific comment.
>
> To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
>
> For queries about this service, please contact Infrastructure at:
> users@infra.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
> For additional commands, e-mail: issues-help@solr.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] tflobbe commented on pull request #1931: SOLR-16978: Be case insensitive when parsing booleans from text
Posted by "tflobbe (via GitHub)" <gi...@apache.org>.
tflobbe commented on PR #1931:
URL: https://github.com/apache/solr/pull/1931#issuecomment-1724631857
@gerlowskija Any thoughts here? I'm on the fence. I don't really love the leniency with which we are reading boolean params here, it seems more useful for configuration files than it is for request parameters, but that's what other parts of the code are using, so I also want to consider consistency with other APIs.
As far as I can tell, pre-Solr9 most Collections API parameters `ZkNodeProps`, which uses `Boolean.getBoolean` (case insensitive), so that's why they worked before and not now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org