You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

通过API触发dbt Job:github_pull_request_id参数有效值咨询

解决dbt Cloud API触发Job时github_pull_request_id参数无效的问题

问题描述

我希望在GitHub CI流水线中,当PR被批准时通过API触发dbt的CI Job。根据dbt Cloud API文档,触发Job有三个可选参数:git_sha、git_branch或github_pull_request_id。由于PR批准后GitHub会修改ref,无法直接使用git_branch;git_sha是可行方案,但我尝试使用github_pull_request_id参数时出现错误。

请求示例

curl --location 'https://cloud.getdbt.com/api/v2/accounts/acc_id/jobs/jb_id/run/' \
--header 'Authorization: Token token' \
--form 'cause="Triggered by GH Actions"' \
--form 'github_pull_request_id="3209"' \
--form 'schema_override="DBT_CLOUD_PR_81231_3209"'

错误信息

"github_pull_request_id": "'3209' is not valid under any of the given schemas"

解决方案

github_pull_request_id参数的预期值就是GitHub PR的编号(即你PR页面URL中的数字,比如https://github.com/owner/repo/pull/3209里的3209),问题出在参数的传递格式上:

dbt Cloud API要求该参数为整数类型,而你之前的请求通过--form传递了带引号的字符串值"3209",导致格式校验失败。

修改后的正确请求如下:

curl --location 'https://cloud.getdbt.com/api/v2/accounts/acc_id/jobs/jb_id/run/' \
--header 'Authorization: Token token' \
--form 'cause="Triggered by GH Actions"' \
--form 'github_pull_request_id=3209' \
--form 'schema_override="DBT_CLOUD_PR_81231_3209"'

只需去掉github_pull_request_id值的引号,直接传递数字即可。


内容的提问来源于stack exchange,提问作者LMF

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 05:37:10