Skip to content

Elide null macros key for unit test overrides - #16011

Open
CallumFriend-MP wants to merge 1 commit into
dbt-labs:mainfrom
CallumFriend-MP:fix/unit-test-overrides-macros-null
Open

Elide null macros key for unit test overrides#16011
CallumFriend-MP wants to merge 1 commit into
dbt-labs:mainfrom
CallumFriend-MP:fix/unit-test-overrides-macros-null

Conversation

@CallumFriend-MP

@CallumFriend-MP CallumFriend-MP commented Aug 20, 2026

Copy link
Copy Markdown

Fixes #16009.

dbt parse --use-v2-parser fails with FusionParserSchemaError on any project with a unit test that sets overrides: without macros:, because the parser emits "macros": null and Python's UnitTestOverrides.macros is a non-Optional Dict.

UnitTestOverrides.macros is Verbatim<Option<T>>, not a bare Option<T>. #[skip_serializing_none] matches on the declared outer type, so it does not apply through the wrapper, and Verbatim's Serialize forwards to the inner value. Its siblings env_vars and vars are bare Option<T> and elide correctly. Introduced by 7c17262, which wrapped the field and landed between the a5 and b1 parser releases; 1.12.1 and 1.12.2 raise the parser floor to >=2.0.0b1, so the current release pulls the failing pair by default.

This adds an explicit skip_serializing_if to that one field. Verbatim derefs to T, so the predicate is a one-liner and the wrapper 7c17262 needs is untouched.

Verification

I could not build the monorepo here, so I compiled the exact patched struct in isolation against dbt-yaml 0.9.6 with this repo's dependency versions, including the DbtSchema derive and #[skip_serializing_none]:

macros unset : {"vars":{"some_var":"'x'"}}
macros set   : {"macros":{"run_started_at":"2024-01-01"},"vars":{"some_var":"'x'"}}
round-trip   : macros.is_none()=true vars=true

Line 1 is the fix. Line 2 confirms a populated macros map still serialises, so the datetime behaviour 7c17262 was added for is preserved. Line 3 confirms the elided form deserialises back to None. Before the change the same struct emits {"macros":null,"vars":{"some_var":"'x'"}}, reproducing the reported failure byte for byte. #16009 has a repro needing no warehouse connection.

I have not run dbt-core's own suite. Understood that fork CI needs ci:approve-public-fork-ci and that it clears on each push.

Not included

A Python-side coercion of None to {} in UnitTestOverrides would also fix it, cover vars and env_vars, and unlike this change would help projects already pinned to a released b-series parser. It belongs on 1.latest rather than here, so I have left it out and noted it on the issue.

@CallumFriend-MP
CallumFriend-MP requested a review from a team as a code owner August 20, 2026 09:55
@cla-bot

cla-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, please reach out through a comment on this PR.

CLA has not been signed by users: @CallumFriend-MP

codescene-delta-analysis[bot]

This comment was marked as outdated.

skip_serializing_none only rewrites fields whose declared outer type is Option,
so it cannot elide macros through the Verbatim wrapper and None serializes as an
explicit null. dbt-core then fails to deserialize the fusion-produced manifest,
because UnitTestOverrides.macros is a non-Optional Dict on the Python side.

Fixes dbt-labs#16009
@CallumFriend-MP
CallumFriend-MP force-pushed the fix/unit-test-overrides-macros-null branch from 9b63303 to 58495cc Compare August 20, 2026 10:05
@cla-bot cla-bot Bot added the cla:yes label Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v2 Bug] --use-v2-parser: FusionParserSchemaError when a unit test sets overrides without macros

1 participant