Skip to content

enhancement(common): extend PermissiveBool to match Go's strconv.ParseBool#1290

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 6 commits into
mainfrom
thieman/permissive-bool-go-compat
Mar 31, 2026
Merged

enhancement(common): extend PermissiveBool to match Go's strconv.ParseBool#1290
gh-worker-dd-mergequeue-cf854d[bot] merged 6 commits into
mainfrom
thieman/permissive-bool-go-compat

Conversation

@thieman
Copy link
Copy Markdown
Contributor

@thieman thieman commented Mar 31, 2026

Noticed this as part of working on config support for DD_NO_PROXY_NONEXACT_MATCH which is a boolean config value. Within the existing Agent there is a wide variety of bool parsing going on, but it looks like nodetreemodel is eventually calling out to spf13/cast which eventually gets to strconv.ParseBool. This Go stdlib function allows some string values which will currently error out in Saluki:

ParseBool returns the boolean value represented by the string. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other value returns an error.

This PR extends PermissiveBool to accommodate all of these cases, in addition to its current support for case-insensitive "true" and "false".

…ool string set

Accepts "1", "t", "T", "TRUE", "true", "True" as truthy and
"0", "f", "F", "FALSE", "false", "False" as falsy, matching the
exact set of Go's strconv.ParseBool.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dd-octo-sts dd-octo-sts Bot added the area/core Core functionality, event model, etc. label Mar 31, 2026
thieman and others added 4 commits March 31, 2026 12:19
…s, drop serde_json dev-dep

Add a case-insensitive fallback for "true"/"false" after the Go strconv.ParseBool
exact matches so arbitrary case variants (e.g. "tRuE") continue to be accepted,
preventing regression from prior behavior. Rewrite tests using serde's own value
deserializers to remove the serde_json dev-dependency.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…sfy clippy

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…strconv.ParseBool

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…allback for true/false

The explicit TRUE/true/True and FALSE/false/False arms are redundant now that the
case-insensitive fallback handles them. Keep only the short forms (1/t/T, 0/f/F).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@thieman thieman marked this pull request as ready for review March 31, 2026 16:34
@thieman thieman requested a review from a team as a code owner March 31, 2026 16:34
@tobz tobz changed the title enhancement(common): extend PermissiveBool to match Go strconv.ParseBool enhancement(common): extend PermissiveBool to match Go's strconv.ParseBool Mar 31, 2026
Copy link
Copy Markdown
Member

@tobz tobz left a comment

Choose a reason for hiding this comment

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

Seems like we're missing basic unit tests that it actually accepts the short forms?

…falsy tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 4a0848b into main Mar 31, 2026
58 of 60 checks passed
dd-octo-sts Bot pushed a commit that referenced this pull request Mar 31, 2026
…arseBool` (#1290)

Noticed this as part of working on config support for `DD_NO_PROXY_NONEXACT_MATCH` which is a boolean config value. Within the existing Agent there is a wide variety of bool parsing going on, but it looks like `nodetreemodel` is eventually calling out to `spf13/cast` which eventually gets to `strconv.ParseBool`. This Go stdlib function allows some string values which will currently error out in Saluki:

> ParseBool returns the boolean value represented by the string. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other value returns an error.

This PR extends `PermissiveBool` to accommodate all of these cases, in addition to its current support for case-insensitive "true" and "false".

Co-authored-by: travis.thieman <travis.thieman@datadoghq.com> 4a0848b
@tobz tobz deleted the thieman/permissive-bool-go-compat branch April 10, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Core functionality, event model, etc. mergequeue-status: done

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants