Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions sqlmesh/dbt/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def load_yaml(source: str | Path) -> t.Dict:
raise ConfigError(f"{source}: {ex}" if isinstance(source, Path) else f"{ex}")


def parse_meta(v: t.Dict[str, t.Any]) -> t.Dict[str, t.Any]:
def parse_meta(v: t.Optional[t.Dict[str, t.Any]]) -> t.Dict[str, t.Any]:
if v is None:
return {}
for key, value in v.items():
if isinstance(value, str):
v[key] = try_str_to_bool(value)
Expand Down Expand Up @@ -115,7 +117,7 @@ def _validate_list(cls, v: t.Union[str, t.List[str]]) -> t.List[str]:

@field_validator("meta", mode="before")
@classmethod
def _validate_meta(cls, v: t.Dict[str, t.Union[str, t.Any]]) -> t.Dict[str, t.Any]:
def _validate_meta(cls, v: t.Optional[t.Dict[str, t.Union[str, t.Any]]]) -> t.Dict[str, t.Any]:
return parse_meta(v)
Comment on lines +120 to 121
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.

_FIELD_UPDATE_STRATEGY: t.ClassVar[t.Dict[str, UpdateStrategy]] = {
Expand Down
6 changes: 6 additions & 0 deletions tests/fixtures/dbt/sushi_test/models/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,14 @@ sources:
schema: raw
tables:
- name: items
config:
meta:
- name: orders
config:
meta:
- name: order_items
config:
meta:
freshness:
warn_after: {count: 10, period: hour}
error_after: {count: 11, period: hour}
Expand Down
Loading