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

Python集成Pactflow发布提供者验证结果时参数报错

问题解决:Pactflow提供者验证发布结果时报错"Please set the app_version..."

问题原因

当开启publish_verification_results: True时,Pactflow要求必须指定提供者的应用版本,但你当前使用的provider_app_version并非底层Ruby依赖所识别的参数名,底层期望的参数是app_version。

修复步骤

修改default_opts中的参数,将provider_app_version替换为app_version,调整后的代码如下:

# Define the provider and consumer names
PROVIDER_NAME = 'BackendService'
CONSUMER_NAME = 'FrontendApp'

# Create a new Verifier instance
verifier = Verifier(provider=PROVIDER_NAME, provider_base_url="http://127.0.0.1:8080")

# Configure the Verifier to use Pactflow as the broker
default_opts = {
    'pact_url': 'https://my_url.pactflow.io/pacts/provider/BackendService/consumer/FrontendApp/version/1.0.0',
    'broker_url': 'https://my_url.pactflow.io',
    'broker_token': 'my token',
    'publish_verification_results': True,
    'app_version': '1.0.0',  # 替换原provider_app_version为app_version
    'consumer_app_version': '1.0.0'
}
output, logs = verifier.verify_with_broker(**default_opts)
print(output)

额外说明

  • app_version对应提供者的版本号,Pactflow需要用这个版本来关联验证结果与具体的提供者版本
  • 无需保留publish-version参数,app_version已包含所需的版本信息,重复设置可能引发冲突

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 11:22:24