Skip to content

Fix float precision loss in jsonschema ParseFloat#4992

Open
denik wants to merge 6 commits intomainfrom
denik/random-bugfixes-3
Open

Fix float precision loss in jsonschema ParseFloat#4992
denik wants to merge 6 commits intomainfrom
denik/random-bugfixes-3

Conversation

@denik
Copy link
Copy Markdown
Contributor

@denik denik commented Apr 16, 2026

Changes

  • Fix ParseFloat to use 64-bit precision instead of 32-bit, which caused silent precision loss for float values in bundle init template prompts (e.g., 1.1 became 1.100000023841858).

Tests

  • Updated unit test to use exact float comparison, verifying the precision fix.

@denik denik requested a review from pietern April 16, 2026 14:17
@denik denik force-pushed the denik/random-bugfixes-3 branch 3 times, most recently from 6ffc4be to b6f655c Compare April 22, 2026 16:09
denik added 6 commits April 28, 2026 15:20
strconv.ParseFloat(s, 32) parses the string as a float32 and then
promotes it to float64, silently losing precision. For example, "1.1"
becomes 1.100000023841858 instead of 1.1. This affects users who
specify number-type template variables during `databricks bundle init`.

Change the bit size from 32 to 64 to preserve full float64 precision.

Task: 001.md

Co-authored-by: Isaac
Adds an acceptance test that renders a template with a number-type
variable (default 1.1). Prior to the ParseFloat bit-size fix the
value rendered as 1.100000023841858; with the fix it renders as 1.1.

Task: 005.md

Co-authored-by: Isaac
The lint check originally failed with 'parallel golangci-lint is running',
caused by concurrent worktrees colliding on the shared /tmp lockfile.
Restore allow-parallel-runners: true in .golangci.yaml.

After unblocking, testifylint's float-compare also flagged two assert.Equal
calls in libs/jsonschema/utils_test.go (introduced by the float precision
fix). Switch to assert.InDelta with delta=0 to express exact equality and
satisfy the linter.

Task: 006.md

Co-authored-by: Isaac
Drop the unrelated allow-parallel-runners restoration in .golangci.yaml
that was bundled into 2b6721afc. The parallel-runner setting is an
environment-only workaround (per-worktree TMPDIR is the durable fix,
tracked separately) and adding it here violates the repo's one-change
per-PR rule.

With the lint config no longer enabling testifylint's float-compare
across this branch, reword the two affected assertions to use
assert.Equal directly with an inline nolint:testifylint comment that
documents why exact float64 equality is the property under test.

Task: 007.md

Co-authored-by: Isaac
@denik denik force-pushed the denik/random-bugfixes-3 branch from b6f655c to 1da53a5 Compare April 28, 2026 15:45
@denik denik temporarily deployed to test-trigger-is April 28, 2026 15:45 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is April 28, 2026 15:45 — with GitHub Actions Inactive
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