Skip to content

[BUG] --vars option can't handle YAML #402

@yu-iskw

Description

@yu-iskw

Describe the bug
The --vars option in dbt build (e.g., dbt build --vars path/to/vars.yml) is unable to read variables from a YAML file. Instead, it expects the YAML content to be passed directly as a string argument. While it can parse JSON content when provided as a string, it does not support reading YAML content from a specified file path.

What version of dbt Fusion is this bug in? (find out by running dbt --version)
[To be filled in by user]

Is this a discrepancy between the dbt Fusion Engine and dbt Core? Check one.

  • YES
  • NO

To Reproduce

Open this workspace and follow the instructions in the README, or:

  1. Create a vars.yml file with some content:

    key1: value1
    key2: value2
  2. Attempt to run dbt build with the --vars option pointing to the file:

    $ dbtf ls --vars "$(cat vars.yml)"
    error: invalid value 'key1: value1
    key2: value2' for '--vars <VARS>': Invalid key-value pair: 'key1: value1
    key2: value2'. Expected format: 'key: value'.
    
    For more information, try '--help'.

    Expected behavior: The variables from vars.yml should be loaded and available.
    Observed behavior: The command fails to parse vars.yml as a file, and instead attempts to parse "vars.yml" as a literal YAML/JSON string, leading to an error.

Expected behavior
The --vars option should be able to accept a file path to either a YAML or a JSON file (e.g., dbt build --vars path/to/vars.yml or dbt build --vars path/to/vars.json) and correctly parse its contents, similar to how dbt Core handles this functionality. This would provide a more convenient way to manage and pass variables, especially for complex or numerous variables.

Screenshots
N/A

Operating System and CPU Type (please complete the following information):

  • Mac/Windows/Linux?
  • X86 or ARM?

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdiscrepancydiscrepancy between the dbt Fusion Engine and dbt Corehas-reproHas a reproducible example

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions