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

Specifying dbt-cloud-host in cli not working while using Env works properly #71

Closed
lefthanded78 opened this issue Apr 12, 2023 · 2 comments

Comments

@lefthanded78
Copy link
Contributor

When specifying the dbt-cloud-host (e.g. emea.dbt.com) in the cli-arguments when starting a job, the job is started with the correct url.
BUT the loop for checking the run-state does not use the overridden host, but the default host cloud.getdbt.com, causing the check to fail with:

Traceback (most recent call last):
  File "/home/aretz/git/dbt_bi-vertrieb/.venv/bin/dbt-cloud", line 8, in <module>
    sys.exit(dbt_cloud())
  File "/home/aretz/git/dbt_bi-vertrieb/.venv/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/aretz/git/dbt_bi-vertrieb/.venv/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/aretz/git/dbt_bi-vertrieb/.venv/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/aretz/git/dbt_bi-vertrieb/.venv/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/aretz/git/dbt_bi-vertrieb/.venv/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/aretz/git/dbt_bi-vertrieb/.venv/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/aretz/git/dbt_bi-vertrieb/.venv/lib/python3.9/site-packages/dbt_cloud/cli.py", line 117, in run
    status = DbtCloudRunStatus(response.json()["data"]["status"])
TypeError: 'NoneType' object is not subscriptable

By drilling through the code, I found out, that the root problem was a <Response [401]>, while getting the run-state, because the API of cloud.getdbt.com is accessed where the used token is not valid.

Changing the cli.py (lines 109 - 114) from:

            run_get_command = DbtCloudRunGetCommand(
                api_token=command.api_token,
                account_id=command.account_id,
                run_id=run_id
            )

to

            run_get_command = DbtCloudRunGetCommand(
                api_token=command.api_token,
                account_id=command.account_id,
                dbt_cloud_host=command.dbt_cloud_host,
                run_id=run_id
            )

solves the problem. I'm double hefthanded and a python-novice and therefore not quite sure if it is the right place to fix this issue.

lefthanded78 pushed a commit to lefthanded78/dbt-cloud-cli that referenced this issue Apr 12, 2023
@stumelius
Copy link
Contributor

Thanks for reporting this ❤️

stumelius pushed a commit that referenced this issue Apr 13, 2023
* fixed issue #71

* remove stub from cli.py

---------

Co-authored-by: Marcel Aretz <[email protected]>
@stumelius
Copy link
Contributor

Closed by #72

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