Skip to content

Fix: Support of the null meta config in dbt model / source definitions#5598

Merged
izeigerman merged 1 commit intomainfrom
fix-null-meta-config-in-dbt
Nov 17, 2025
Merged

Fix: Support of the null meta config in dbt model / source definitions#5598
izeigerman merged 1 commit intomainfrom
fix-null-meta-config-in-dbt

Conversation

@izeigerman
Copy link
Contributor

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where null/empty meta configuration values in dbt model and source definitions would cause errors. When YAML specifies meta: without a value, it's parsed as None, which previously caused crashes when the code tried to iterate over the dictionary.

Key Changes:

  • Added null handling in the parse_meta function to return an empty dictionary when v is None
  • Updated type annotations to accept Optional[Dict[str, Any]] for the _validate_meta validator
  • Added test cases with null meta: values in the test fixture to ensure the fix works

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
sqlmesh/dbt/common.py Added null-check in parse_meta() function and updated type annotation for _validate_meta() to handle None values
tests/fixtures/dbt/sushi_test/models/schema.yml Added test cases with empty meta: config for three source tables to validate null handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +120 to 121
def _validate_meta(cls, v: t.Optional[t.Dict[str, t.Union[str, t.Any]]]) -> t.Dict[str, t.Any]:
return parse_meta(v)
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _validate_persist_docs method (lines 108-111) has a similar vulnerability to the one fixed in _validate_meta - it doesn't handle the case where v could be None (when persist_docs: is specified without a value in YAML). Consider applying the same null-check pattern for consistency and robustness. The same issue exists for _validate_dict (lines 99-106) used by the docs field.

Copilot uses AI. Check for mistakes.
@izeigerman izeigerman merged commit b9d0f91 into main Nov 17, 2025
42 checks passed
@izeigerman izeigerman deleted the fix-null-meta-config-in-dbt branch November 17, 2025 20:24
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.

3 participants