Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is there an ability to add support for passing --vars to the dbt_command? #65

Open
ari-stern opened this issue Jun 10, 2024 · 2 comments

Comments

@ari-stern
Copy link

i believe because of the need to have a colon the yaml isnt playing nicely, unless im missing something

example:

    - name: dbt-deps
      uses: mwhitaker/dbt-action@v1.7.3
      with:
        dbt_command: "dbt deps --target pr --vars 'schema_id: 123' --profiles-dir ."

i consistently get an error like this no matter which syntax for vars i try:

Error: Invalid value for '--vars': String ''schema_id:' is not valid YAML

I also tried some other fixes like prefacing the dbt_command string with a | or a > or escaping the quotes, but i think the problem is the colon

if you have any other suggested fixes for this that would be awesome!

@dylanvanw
Copy link

dylanvanw commented Jul 24, 2024

Found that the issue is the space in the --vars yaml. The parser that reads the dbt_command string and translates it into argument tokens sees the space in the vars yaml as a separator between tokens.

More explanation on the whitespace being seen as a token: https://unix.stackexchange.com/questions/234755/command-line-processing-tokens-and-metacharacters

This issue is solved in other yaml configuration files by seperating the command from the argument list, like is done here: twpayne/chezmoi#1706
Example:

 dbt_command:
   - command: dbt
     args:
       - deps
       - --target
       - pr
       - --vars
       - 'schema_id: 123'
       - --profiles-dir
       - .

or this:

dbt_command:
   - command: dbt
     args: ['deps', '--target', 'pr', '--vars', 'schema_id: 123', '--profiles-dir', '.']

There might be another solution if I can find where the dbt_command is translated into what is executed in the docker container. The issue is that I cannot seem to find the part of the code in this repo that is responsible for using the provided value for dbt_command in the action. I can only find the input value here https://github.com/mwhitaker/dbt-action/blob/master/action.yml#L6

@mwhitaker could you point me in the right direction on how dbt_command value is executed in the docker container during the action execution?

@ari-stern
Copy link
Author

Found that the issue is the space in the --vars yaml. The parser that reads the dbt_command string and translates it into argument tokens sees the space in the vars yaml as a separator between tokens.

More explanation on the whitespace being seen as a token: https://unix.stackexchange.com/questions/234755/command-line-processing-tokens-and-metacharacters

This issue is solved in other yaml configuration files by seperating the command from the argument list, like is done here: twpayne/chezmoi#1706 Example:

 dbt_command:
   - command: dbt
     args:
       - deps
       - --target
       - pr
       - --vars
       - 'schema_id: 123'
       - --profiles-dir
       - .

or this:

dbt_command:
   - command: dbt
     args: ['deps', '--target', 'pr', '--vars', 'schema_id: 123', '--profiles-dir', '.']

There might be another solution if I can find where the dbt_command is translated into what is executed in the docker container. The issue is that I cannot seem to find the part of the code in this repo that is responsible for using the provided value for dbt_command in the action. I can only find the input value here https://github.com/mwhitaker/dbt-action/blob/master/action.yml#L6

@mwhitaker could you point me at the line of code how dbt_command value is executed in the docker container during the action execution?

thanks appreciate the reply here!

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

No branches or pull requests

2 participants