From 1d62c585d9aeef28360ba88c3ab0784481b1d2f2 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Fri, 20 Nov 2026 09:35:24 +0000 Subject: [PATCH 1/2] Accept whole-number floats returned as ints by the Python mutator JSON doesn't tell 1.0 from 1, so a float variable default comes back from Python as an int. Treat an int equal to the original float as unchanged and keep the original value. Co-authored-by: Isaac --- .../numeric-variable-default/output.txt | 16 --------------- .../mutator/python/apply_python_output.go | 14 ++++++++++++- .../python/apply_python_output_test.go | 20 +++++++++++++++++++ 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/acceptance/bundle/python/numeric-variable-default/output.txt b/acceptance/bundle/python/numeric-variable-default/output.txt index 4f4fcba1008..793a591877c 100644 --- a/acceptance/bundle/python/numeric-variable-default/output.txt +++ b/acceptance/bundle/python/numeric-variable-default/output.txt @@ -7,28 +7,16 @@ === leading_zero >>> uv run [UV_ARGS] -q [CLI] bundle validate -t leading_zero --output json -Error: internal error when merging output of Python mutator: unexpected change at "variables.id.default" (update) - - -Exit code: 1 {"default":12345678901234,"value":12345678901234} === float_whole >>> uv run [UV_ARGS] -q [CLI] bundle validate -t float_whole --output json -Error: internal error when merging output of Python mutator: unexpected change at "variables.id.default" (update) - - -Exit code: 1 {"default":1,"value":1} === exponent >>> uv run [UV_ARGS] -q [CLI] bundle validate -t exponent --output json -Error: internal error when merging output of Python mutator: unexpected change at "variables.id.default" (update) - - -Exit code: 1 {"default":1000,"value":1000} === float_fraction @@ -39,10 +27,6 @@ Exit code: 1 === complex >>> uv run [UV_ARGS] -q [CLI] bundle validate -t complex --output json -Error: internal error when merging output of Python mutator: unexpected change at "variables.id.default.nested" (update) - - -Exit code: 1 {"default":{"nested":1},"value":{"nested":1}} === huge diff --git a/bundle/config/mutator/python/apply_python_output.go b/bundle/config/mutator/python/apply_python_output.go index fb5452d3b4f..b449af2dd18 100644 --- a/bundle/config/mutator/python/apply_python_output.go +++ b/bundle/config/mutator/python/apply_python_output.go @@ -135,7 +135,11 @@ func createOverrideVisitor(leftRoot, rightRoot dyn.Value) (applyPythonOutputResu return right, nil } }, - VisitUpdate: func(valuePath dyn.Path, _, right dyn.Value) (dyn.Value, error) { + VisitUpdate: func(valuePath dyn.Path, left, right dyn.Value) (dyn.Value, error) { + if isWholeFloatAsInt(left, right) { + return left, nil + } + if !valuePath.HasPrefix(resourcesPath) { return dyn.InvalidValue, fmt.Errorf("unexpected change at %q (update)", valuePath.String()) } @@ -211,3 +215,11 @@ func isOmitemptyDelete(left dyn.Value) bool { return false } } + +// isWholeFloatAsInt reports whether right is the int Python returns for the float left. +// JSON doesn't tell 1.0 from 1, so a float such as a variable default of 1.0 comes +// back from Python as an int. +func isWholeFloatAsInt(left, right dyn.Value) bool { + return left.Kind() == dyn.KindFloat && right.Kind() == dyn.KindInt && + left.MustFloat() == float64(right.MustInt()) +} diff --git a/bundle/config/mutator/python/apply_python_output_test.go b/bundle/config/mutator/python/apply_python_output_test.go index 94d7e7c39cc..9a50393b7f2 100644 --- a/bundle/config/mutator/python/apply_python_output_test.go +++ b/bundle/config/mutator/python/apply_python_output_test.go @@ -10,6 +10,7 @@ import ( "github.com/databricks/cli/libs/dyn" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) type applyPythonOutputTestCase struct { @@ -185,6 +186,25 @@ func TestMergeOutput_disallowUpdate(t *testing.T) { assert.EqualError(t, err, `unexpected change at "not_resource" (update)`) } +func TestMergeOutput_wholeFloatAsInt(t *testing.T) { + input := mapOf("not_resource", dyn.V(1.0)) + output := mapOf("not_resource", dyn.V(1)) + + merged, _, err := applyPythonOutput(input, output) + + require.NoError(t, err) + assert.Equal(t, input.Get("not_resource"), merged.Get("not_resource")) +} + +func TestMergeOutput_disallowFloatToDifferentInt(t *testing.T) { + input := mapOf("not_resource", dyn.V(1.5)) + output := mapOf("not_resource", dyn.V(1)) + + _, _, err := applyPythonOutput(input, output) + + assert.EqualError(t, err, `unexpected change at "not_resource" (update)`) +} + type overrideVisitorOmitemptyTestCase struct { name string path dyn.Path From c942a1fea24064c6beaf242439b9bcc39ac0168f Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Fri, 20 Nov 2026 09:39:22 +0000 Subject: [PATCH 2/2] Add changelog entry Co-authored-by: Isaac --- .nextchanges/bundles/7842.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nextchanges/bundles/7842.md diff --git a/.nextchanges/bundles/7842.md b/.nextchanges/bundles/7842.md new file mode 100644 index 00000000000..62683df3123 --- /dev/null +++ b/.nextchanges/bundles/7842.md @@ -0,0 +1 @@ +* Fix `bundle` commands failing with "unexpected change at variables.X.default" when a bundle with Python code has a variable default such as `1.0`, `1e3` or `0012345678901234`.