Hi team, running a dbt-operation with meltano (exe...
# troubleshooting
d
Hi team, running a dbt-operation with meltano (executed via BashOperator), I am getting errors. The same task executed on a host that runs standalone DBT executes just fine. Wondering if this is to do with how meltano parses and transmits arguments to DBT cli?
Copy code
INFO - Running command: cd /project/transform &&     meltano invoke dbt run-operation execute_grant --args '{schemas:[dwh], user: looker}'     --profiles-dir /project/transform
    
 INFO - Output:
 INFO - 11:55:06  Running with dbt=1.0.1
 INFO - 11:55:06  Unable to do partial parsing because config vars, config profile, or config target have changed
 INFO - 11:55:10  ========== Begin Summary ==========
 INFO - 11:55:10  ========== End Summary ==========
 INFO - 11:55:11  The YAML provided in the --vars argument is not valid.
 INFO - 11:55:11  Encountered an error while running operation: Runtime Error
 INFO -   Syntax error near line 1
 INFO -   ------------------------------
 INFO -   1  | {schemas:[dwh], user: looker}
 INFO - 
 INFO -   Raw Error:
 INFO -   ------------------------------
 INFO -   while scanning a plain scalar
 INFO -     in "<unicode string>", line 1, column 2
 INFO -   found unexpected ':'
 INFO -     in "<unicode string>", line 1, column 9
 INFO - Command exited with return code 1
 ERROR - Bash command failed. The command returned a non-zero exit code.
It seems debug logs do show this isn't interpreted correctly, since the array generated is as bellow 🤔 Any workaround?
2022-02-03T13:31:03.586735Z [debug  ] Invoking: ['/project/.meltano/transformers/dbt/venv/bin/dbt', 'run-operation', 'execute_grant', '--args', '{schemas:[dwh], user: looker}', '--profiles-dir', '/project/transform']
e
Hi @david_lequin! Can you try adding a space between the key and value in your yaml string? i.e.
{schemas: [dwh], user: looker}
Copy code
$ .meltano/transformers/dbt/venv/bin/python
Python 3.9.9 (main, Dec 17 2021, 12:54:09) 
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from dbt.clients import yaml_helper
>>> yaml_helper.load_yaml_text("{schemas:[dwh], user: looker}")
Traceback (most recent call last):
  File "/Users/edgarramirez/Code/meltano-personal/.meltano/transformers/dbt/venv/lib/python3.9/site-packages/dbt/clients/yaml_helper.py", line 64, in load_yaml_text
    return safe_load(contents)
  File "/Users/edgarramirez/Code/meltano-personal/.meltano/transformers/dbt/venv/lib/python3.9/site-packages/dbt/clients/yaml_helper.py", line 59, in safe_load
    return yaml.load(contents, Loader=SafeLoader)
  File "/Users/edgarramirez/Code/meltano-personal/.meltano/transformers/dbt/venv/lib/python3.9/site-packages/yaml/__init__.py", line 81, in load
    return loader.get_single_data()
  File "/Users/edgarramirez/Code/meltano-personal/.meltano/transformers/dbt/venv/lib/python3.9/site-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
  File "yaml/_yaml.pyx", line 670, in yaml._yaml.CParser.get_single_node
  File "yaml/_yaml.pyx", line 860, in yaml._yaml.CParser._parse_next_event
yaml.scanner.ScannerError: while scanning a plain scalar
  in "<unicode string>", line 1, column 2
found unexpected ':'
  in "<unicode string>", line 1, column 9

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/edgarramirez/Code/meltano-personal/.meltano/transformers/dbt/venv/lib/python3.9/site-packages/dbt/clients/yaml_helper.py", line 71, in load_yaml_text
    raise dbt.exceptions.ValidationException(error)
dbt.exceptions.ValidationException: Runtime Error
  Syntax error near line 1
  ------------------------------
  1  | {schemas:[dwh], user: looker}
  
  Raw Error:
  ------------------------------
  while scanning a plain scalar
    in "<unicode string>", line 1, column 2
  found unexpected ':'
    in "<unicode string>", line 1, column 9
>>> yaml_helper.load_yaml_text("{schemas: [dwh], user: looker}")
{'schemas': ['dwh'], 'user': 'looker'}
d
Oh, that's right, seems to have been invalid all along
Thanks @edgar_ramirez_mondragon! Nice one
e
I'm glad that was it! 😄