databricks / cli

Databricks CLI
Other
115 stars 39 forks source link

Properly deal with nil values in `convert.FromTyped` #1511

Closed pietern closed 1 week ago

pietern commented 1 week ago

Changes

When a configuration defines:

run_as:

It first showed up as run_as -> nil in the dynamic configuration only to later be converted to run_as -> {} while going through typed conversion. We were using the presence of a key to initialize an empty value. This is incorrect and it should have remained a nil value.

This conversion was happening in convert.FromTyped where any struct always returned a map value. Instead, it should only return a map value in any one of these cases: 1) the struct has elements, 2) the struct was originally a map in the dynamic configuration, or 3) the struct was initialized to a non-empty pointer value.

Stacked on top of #1516 and #1518.

Tests