Skip to content

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

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

izeigerman merged 1 commit into
mainfrom
fix-null-meta-config-in-dbt

Conversation

@izeigerman

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 thread sqlmesh/dbt/common.py
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)

Copilot AI Nov 17, 2025

Copy link

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
@izeigerman
izeigerman deleted the fix-null-meta-config-in-dbt branch November 17, 2025 20:24
scottypate added a commit to scottypate/sqlmesh that referenced this pull request May 18, 2026
* Fix(table_diff): Widen the data types that --decimals applies to (SQLMesh#5542)

* linting and style changes

* fix: dbt as_bool and as_number filters should return their original input values (SQLMesh#5532)

* fix: include schema temp table (SQLMesh#5545)

* Fix: Respect mssql_merge_exists flag and use merge as a strategy (SQLMesh#5544)

* fix: ensure _get_data_objects respects snapshots with different schemas (SQLMesh#5515)

Co-authored-by: Themis Valtinos <73662635+themisvaltinos@users.noreply.github.com>

* Fix: Add dbt-core 1.2.0 support (SQLMesh#5547)

* Fix: do not reduce empty generator when evaluating snapshots (SQLMesh#5548)

* Fix: Unexpected backfill of a parent when an interval outside the parent's range is restated for a child (SQLMesh#5551)

* Chore!: bump sqlglotrs to 27.28.0 (SQLMesh#5556)

* Feat: Check freshness for mixed external & sqlmesh models (SQLMesh#5499)

* Fix: create_test error with query and CTEs included (SQLMesh#5559)

* Fix: Incorrect treatment of the model's table as missing when processing batches with index > 0 (SQLMesh#5560)

* Fix: Only selected models need to be promoted when --inlclude-unmodified flag is provided (SQLMesh#5561)

* fix: added missing execution_time param for CLI audit command (SQLMesh#5563)

* Fix: Cache upstream dependencies when building the evaluation DAG in scheduler (SQLMesh#5569)

* Fix: Temporary disable lsp benchmarks

* Fix: Make macro evaluator locals available from macro calls in jinja (SQLMesh#5568)

* Fix: Require the cache for upstream deps in the scheduler (SQLMesh#5571)

* Fix: always sort Python model dfs in unit tests (SQLMesh#5575)

* ci: fix benchmark running (SQLMesh#5570)

* Feat: use proper `MERGE` statement for Fabric instead of the logical equivalent (SQLMesh#5586)

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

* Docs: Fix set `invalidate_hard_deletes` default to `False` in SCD Type 2 models (SQLMesh#5596)

* Feat: NoMissingUnitTest linter rule (SQLMesh#5294)

* Fix: Include column types in Databricks materialized views with comments (SQLMesh#5578)

* fix(fabric): Alter table workaround (SQLMesh#5511)

Co-authored-by: Toby Mao <toby.mao@gmail.com>

* Chore(deps): Bump actions/setup-python from 5 to 6 (SQLMesh#5322)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Chore(deps): Bump astral-sh/setup-uv from 6 to 7 (SQLMesh#5537)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Chore(deps): Bump actions/setup-node from 4 to 6 (SQLMesh#5553)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Chore!: clean up unit test selection (SQLMesh#5615)

* Feat: add support for METADATA_SCHEMA in ducklake config.yml (SQLMesh#5616)

* Chore(deps): Bump actions/upload-artifact from 4 to 5 (SQLMesh#5564)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fix(databricks): Add column type only along materialized view comments (SQLMesh#5617)

* Fix: Embedded Model Type Should Not Accept Any Audit (SQLMesh#5577)

Co-authored-by: Jo <46752250+georgesittas@users.noreply.github.com>

* fix: CI/CD Bot exit early before applying plan on unmergeable PR (SQLMesh#5590)

* Chore: Disable snowflake tests temporarily (SQLMesh#5620)

* Fix: Use categorization config in cicd bot environment summary (SQLMesh#5622)

* Fix: Include staged changes in the git selector (SQLMesh#5624)

* chore: remove dbt from sqlmesh tests package (SQLMesh#5626)

* fix: set `ExternalModel`'s default `kind` to `ExternalKind()` (SQLMesh#5634)

* Feat(trino): Introduce custom timestamp type mapping (SQLMesh#5635)

* Chore: Update type annotation for pandas and pandas-stubs >= v2.3.3 (SQLMesh#5637)

* Fix bigquery cli engine config test

* Update naming conventions and how to set the property

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Erin Drummond <erin.dru@gmail.com>
Co-authored-by: David Dai <ddai@tobikodata.com>
Co-authored-by: Ryan Eakman <6326532+eakmanrq@users.noreply.github.com>
Co-authored-by: Themis Valtinos <73662635+themisvaltinos@users.noreply.github.com>
Co-authored-by: Alexander Butler <41213451+z3z1ma@users.noreply.github.com>
Co-authored-by: Chris Rericha <67359577+crericha@users.noreply.github.com>
Co-authored-by: Jo <46752250+georgesittas@users.noreply.github.com>
Co-authored-by: Iaroslav Zeigerman <zeigerman.ia@gmail.com>
Co-authored-by: Vaggelis Danias <daniasevangelos@gmail.com>
Co-authored-by: Trey Spiller <1831878+treysp@users.noreply.github.com>
Co-authored-by: Anatoli Makarevich <makaroni4@gmail.com>
Co-authored-by: Ben <9087625+benfdking@users.noreply.github.com>
Co-authored-by: Mattias Thalén <bitter-polders0x@icloud.com>
Co-authored-by: Nick Nowicki <35818104+nnowicki@users.noreply.github.com>
Co-authored-by: Cortland Goffena <30168413+cmgoffena13@users.noreply.github.com>
Co-authored-by: Andreas Fred-Ojala <andreasfo@gmail.com>
Co-authored-by: Andreas <65893109+fresioAS@users.noreply.github.com>
Co-authored-by: Toby Mao <toby.mao@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: bearInTheRoad <60107263+bearInTheRoad@users.noreply.github.com>
Co-authored-by: Brian Crant <17074379+bcrant@users.noreply.github.com>
Co-authored-by: etonlels <etonlels@gmail.com>
Co-authored-by: Vincent Chan <vchan@users.noreply.github.com>
fresioAS pushed a commit to fresioAS/sqlmesh that referenced this pull request May 31, 2026
SQLMesh#5598)

Signed-off-by: fresioAS <andreas.fredhoi@three60energy.com>
fresioAS pushed a commit to fresioAS/sqlmesh that referenced this pull request Jul 13, 2026
SQLMesh#5598)

Signed-off-by: fresioAS <andreas.fredhoi@three60energy.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants