Skip to content

fix(dbt): return lists and scalars from fromyaml - #6138

Open
raams95 wants to merge 1 commit into
SQLMesh:mainfrom
raams95:fix/dbt-fromyaml-non-mapping
Open

raams95 wants to merge 1 commit into
SQLMesh:mainfrom
raams95:fix/dbt-fromyaml-non-mapping

Conversation

@raams95

@raams95 raams95 commented Oct 13, 2026

Copy link
Copy Markdown

Description

Fixes #6137.

In dbt projects, SQLMesh's fromyaml builtin wrapped the parsed document in dict(...), so YAML whose top level isn't a mapping came back wrong:

  • A block-style list (- good\n- bad) raised an uncaught ValueError, which failed rendering.
  • A flow-style list ([1, 2]) or a scalar (42) quietly returned None, because the TypeError from dict() is caught and default is returned.

dbt's fromyaml returns yaml.safe_load(value) unchanged. sqlmesh.utils.yaml.load already returns plain Python objects (dict, list, int, ...), so this change drops the dict(...) wrapper and returns the parsed value directly. Mappings give the same result as before, and invalid YAML still returns default.

Test Plan

  • Extended test_yaml in tests/dbt/test_transformation.py with a flow-style list, a block-style list (built with {% set %}, like the example in dbt's docs) and a scalar. On main the test fails: it renders None for [1, 2], and the block-style list raises ValueError: dictionary update sequence element #0 has length 4; 2 is required. With this change it passes.
  • Ran pytest tests/dbt (slow tests included) on Windows: 296 passed, 2 skipped. One test, test_load_custom_materialisations, errored in the parallel run, but it passes on its own both on this branch and on main. To run the sushi_test based tests locally, I replaced the sushi_test/dbt_packages symlinks with directory junctions, since git checks them out as plain files on Windows.
  • ruff check and ruff format --check are clean on the changed files. mypy sqlmesh/dbt/builtin.py only reports the errors my local environment also gives on main (missing sqlmesh._version, signal.SIGUSR1).

Checklist

  • I have run make style and fixed any issues (ran ruff + mypy on the changed files only; on Windows, mypy only shows the same environment errors as on main)
  • I have added tests for my changes (if applicable)
  • All existing tests pass (make fast-test) (ran tests/dbt on Windows and compared against main; I didn't run the full suite)
  • My commits are signed off (git commit -s) per the DCO

The fromyaml builtin wrapped the parsed document in dict(), so YAML
whose top level is not a mapping was mishandled: a block-style list
raised an uncaught ValueError, and a flow-style list or a scalar was
silently returned as None. dbt returns the parsed value as is.

sqlmesh.utils.yaml.load already returns plain Python objects, so return
its result directly. Mappings are unaffected.

Fixes SQLMesh#6137

Signed-off-by: JanakiRamChittineni <341781521+raams95@users.noreply.github.com>
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.

dbt: fromyaml fails on YAML that isn't a mapping (lists, scalars)

1 participant