Skip to content

Gate strict std.format boolean conversions behind a flag - #1069

Merged
stephenamar-db merged 1 commit into
databricks:masterfrom
He-Pin:hepin/format-bool-strict-flag
Jun 30, 2026
Merged

Gate strict std.format boolean conversions behind a flag#1069
stephenamar-db merged 1 commit into
databricks:masterfrom
He-Pin:hepin/format-bool-strict-flag

Conversation

@He-Pin

@He-Pin He-Pin commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Motivation

PR #1053 reverted the stricter std.format boolean conversion behavior so the default can remain compatible with current master. The maintainer asked for a roll-forward with the new behavior behind a flag.

Modification

Add Settings.strictFormatBooleanConversions with default false and expose it through the CLI flag --strict-format-boolean-conversions. Route std.format boolean handling through that setting so default behavior continues coercing true/false to 1/0, while opt-in strict mode rejects booleans for numeric conversion codes and still allows %s.

Result

Case go-jsonnet v0.22.0 jrsonnet 0.5.0-pre99 sjsonnet before sjsonnet after default sjsonnet after strict
'%d' % true error: expected number error: expected number "1" "1" error: expected number or string, got boolean
'%s' % true "true" "true" "true" "true" "true"
CLI flag not available not available not available opt-in flag available numeric boolean conversions rejected

References

Motivation:
PR databricks#1053 reverted the previous std.format boolean conversion change because default behavior must remain compatible. The maintainer asked for a roll-forward with the new behavior behind a flag.

Modification:
Add Settings.strictFormatBooleanConversions and CLI --strict-format-boolean-conversions. Route std.format/% boolean handling through that setting so the default continues to coerce true/false to 1/0 while the flag rejects boolean values for numeric conversions and still allows %s.

Result:
Default std.format behavior remains unchanged. Users can opt in to stricter boolean numeric conversion errors, with evaluator and CLI tests covering both paths.

References:
databricks#1053
@stephenamar-db
stephenamar-db merged commit dda53fa into databricks:master Jun 30, 2026
5 checks passed
@He-Pin
He-Pin deleted the hepin/format-bool-strict-flag branch June 30, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants