Fix: Support of the null meta config in dbt model / source definitions#5598
Fix: Support of the null meta config in dbt model / source definitions#5598izeigerman merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
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_metafunction to return an empty dictionary whenvis None - Updated type annotations to accept
Optional[Dict[str, Any]]for the_validate_metavalidator - 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.
| def _validate_meta(cls, v: t.Optional[t.Dict[str, t.Union[str, t.Any]]]) -> t.Dict[str, t.Any]: | ||
| return parse_meta(v) |
There was a problem hiding this comment.
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.
No description provided.