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

Request failed with status code 401 using a 'Job Admin' service token #27

Open
maxpowis-bp opened this issue Nov 20, 2023 · 3 comments
Open

Comments

@maxpowis-bp
Copy link

maxpowis-bp commented Nov 20, 2023

Hi,
It is my first time trying to use this github-action. So far, I have successfully used the following step specification.

      - id: dbt_cloud_run
        name: Run dbt job on target environment
        run: |
          RESPONSE=$(curl -v -H "Authorization:Token ${{ secrets.DBT_CLOUD_API_TOKEN }}" -H "Content-Type:application/json" \
            -d '{"cause":"Triggered by Github Action"}' \
            https://emea.dbt.com/api/v2/accounts/${{ vars.DBT_CLOUD_ACCOUNT_ID }}/jobs/${{ vars.DBT_CLOUD_JOB_ID }}/run/)
          STATUSCODE=$(echo "$RESPONSE" | jq '.status.code')
          echo "$RESPONSE" | jq '.status.user_message'
          if [[ $STATUSCODE != 200 ]]; then
            echo "$RESPONSE"
            bash -c "exit 1"
          fi

However, I'd be interested in replacing it with this github action as a mean to get the actual job outputs status. So I have tried amending my step as follows:

      - id: dbt_cloud_run
        name: Run dbt job on target environment
        uses: fal-ai/[email protected]
        with:
          dbt_cloud_token: ${{ secrets.DBT_CLOUD_API_TOKEN }}
          dbt_cloud_account_id: ${{ vars.DBT_CLOUD_ACCOUNT_ID }}
          dbt_cloud_job_id: ${{ vars.DBT_CLOUD_JOB_ID }}
          failure_on_error: true

Unfortunately, it fails with the following debug log outputs that seem to indicate my token is not properly configured.

##[debug]Loading env
Run fal-ai/[email protected]
##[debug]Run job body:
##[debug]{
##[debug]  "cause": "Triggered by a GitHub Action"
##[debug]}
Error: There has been a problem with running your dbt cloud job:
Error: Request failed with status code 401
##[debug]Error: Request failed with status code 401
##[debug]    at createError (/home/runner/work/_actions/fal-ai/dbt-cloud-action/v4.3/node_modules/axios/lib/core/createError.js:16:15)
##[debug]    at settle (/home/runner/work/_actions/fal-ai/dbt-cloud-action/v4.3/node_modules/axios/lib/core/settle.js:17:12)
##[debug]    at IncomingMessage.handleStreamEnd (/home/runner/work/_actions/fal-ai/dbt-cloud-action/v4.3/node_modules/axios/lib/adapters/http.js:269:11)
##[debug]    at IncomingMessage.emit (node:events:525:35)
##[debug]    at endReadableNT (node:internal/streams/readable:13[58](***MASKED***):12)
##[debug]    at processTicksAndRejections (node:internal/process/task_queues:83:21)
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Run dbt job on target environment

In my previous implementation, I have used a service token with 'Job Admin' scope on my project. I can see in dbt cloud that my token (a new one with the exact same config) is actually never accessed. Do I need to consider another - more extensive - permission?

Thanks in advance for your support.

@maxpowis-bp
Copy link
Author

Look like to is due to the fact my dbt endpoint is on the domain emea.dbt.com while the https://github.com/fal-ai/dbt-cloud-action/blob/08fd3588f25a91faa328c858664f11daeee5f9f2/index.js#L26C37-L26C37 hardcodes the domain to cloud.getdbt.com

@maxpowis
Copy link
Contributor

As per https://docs.getdbt.com/dbt-cloud/api-v2#/ API base url's can be:

@maxpowis
Copy link
Contributor

Created PR #28

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