Bug
dbt-autofix mangles +-prefixed custom config keys that have dict values when they appear at the top level of models: (or other node-type sections) in dbt_project.yml.
The root cause: changeset_dbt_project_prefix_plus_for_config doesn't check for + prefix in its else branch, it assumes any unrecognised key with a dict value is a project path and recurses into it. rec_check_yaml_path already handles this correctly at nested levels.
Reproduction
# input
models:
+endpoint_settings: &defaults
owner: my-team
lifecycle: production
retentionCategory:
category: internal
subCategory: internal.benchmarking
# actual output — broken
models:
+endpoint_settings: &defaults
retentionCategory:
+category: "internal" # wrong: +prefix on plain data
+meta:
subCategory: internal.benchmarking
+meta:
owner: my-team
lifecycle: production
# expected output
models:
+meta:
endpoint_settings: &defaults
owner: my-team
lifecycle: production
retentionCategory:
category: internal
subCategory: internal.benchmarking
category happens to be a valid dbt config field, so it gets + prefixed. Everything else gets shoved under +meta inside the anchor. This breaks YAML anchor inheritance for any project using <<: *defaults overrides.
Fix
Add elif k.startswith("+") before the else branch in changeset_dbt_project_prefix_plus_for_config, move the key to +meta as a unit instead of recursing. This matches what rec_check_yaml_path already does for nested keys.
Tested on 0.20.2 and 0.20.4.
I can raise a PR incoming.
Bug
dbt-autofixmangles+-prefixed custom config keys that have dict values when they appear at the top level ofmodels:(or other node-type sections) indbt_project.yml.The root cause:
changeset_dbt_project_prefix_plus_for_configdoesn't check for+prefix in itselsebranch, it assumes any unrecognised key with a dict value is a project path and recurses into it.rec_check_yaml_pathalready handles this correctly at nested levels.Reproduction
categoryhappens to be a valid dbt config field, so it gets+prefixed. Everything else gets shoved under+metainside the anchor. This breaks YAML anchor inheritance for any project using<<: *defaultsoverrides.Fix
Add
elif k.startswith("+")before theelsebranch inchangeset_dbt_project_prefix_plus_for_config, move the key to+metaas a unit instead of recursing. This matches whatrec_check_yaml_pathalready does for nested keys.Tested on
0.20.2and0.20.4.I can raise a PR incoming.