(V3) Verifying a contract with a missing content field is always successful when it should error
Los mantenedores suelen responder en 2 días
@JP-Ellis ya está trabajando en esto.
Desde el 6/10/2025.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I'm using the latest version of
pact-python. - I have read the console error message carefully (if applicable).
Description
I have two pacts, one is incorrectly setting the content thus:
"contents": {
"Payload": "exists"
}
The other is correctly setting the content thus:
"contents": {
"content": {
"Payload": "exists"
},
"contentType": "application/json",
"encoded": false
}
When verifying with content that does not match, I expect both pacts to fail to verify. However, the first pact with the incorrect json verifies successfully and there is no error or warning that anything is wrong:
Verifying a pact between my-consumer and my-provider
This works as expected when verifying my-provider (0s loading, 8ms verification)
Given When reading a message from the SQS queue
generates a message which
includes metadata
"contentType" with value "application/json" (OK)
has a matching body (FAILED)
Verifying a pact between other-consumer and my-provider
This is silently ignored while verifying my-provider (0s loading, 6ms verification)
Given When reading a message from the SQS queue
generates a message which
has a matching body (OK)
I'll see if I can get approval to share a producible demo repo, but for now the pacts are:
pact-missing-contents.json
{
"consumer": {
"name": "other-consumer"
},
"provider": {
"name": "my-provider"
},
"interactions": [
{
"_id": "1",
"type": "Asynchronous/Messages",
"description": "This is silently ignored while verifying my-provider",
"providerStates": [
{
"name": "When reading a message from the SQS queue"
}
],
"contents": {
"Payload": "exists"
}
}
],
"metadata": {
"pactRust": {
"ffi": "0.4.22",
"models": "1.2.3"
},
"pactSpecification": {
"version": "4.0"
}
}
}
pact-with-contents.json
{
"consumer": {
"name": "my-consumer"
},
"provider": {
"name": "my-provider"
},
"interactions": [
{
"_id": "2",
"type": "Asynchronous/Messages",
"description": "This works as expected when verifying my-provider",
"providerStates": [
{
"name": "When reading a message from the SQS queue"
}
],
"contents": {
"content": {
"Payload": "exists"
},
"contentType": "application/json",
"encoded": false
}
}
],
"metadata": {
"pactRust": {
"ffi": "0.4.22",
"models": "1.2.3"
},
"pactSpecification": {
"version": "4.0"
}
}
}
And here's an idea of running the verification. I actually use a whole pytest setup with fixtures, but for brevity this ought to be able to reproduce the issue. Again, hopefully I'll be able to share a repo soon.
verify.py
def run_message_handler(name: str, metadata: dict[str, Any] | None) -> Message: """This should fail to match due to missing Payload field for **both** pacts""" return Message(contents=b"{}", content_type="application/json", metadata=None)verifier = Verifier("my-provider")
pact_dir = Path(file).parent / "pacts"
verifier = verifier.add_source(pact_dir).set_error_on_empty_pact()
verifier.message_handler(run_message_handler).verify()
*caveat to "I'm using the latest version": I'm using the latest version available on pypi, version 2.3.1 (as opposed to 2.3.2 available via github releases)
Reproducible demo
No response
Steps to reproduce
step 1: copy the two pact jsons and place them in separate files in a pacts/ directory
step 2: verify the pacts using pact v3, see verify.py for an example
Expected behavior
it should fail with an error due to missing "content" and/or "contentType" but it does not.
You can also enable logging (before step 3) and confirm there is no warning or error logged.
Actual behavior
"other-consumer" pact (pact-missing-contents.json) is verified successfully.
"my-consumer" pact (pact-with-contents.json) fails to verify (due to the mismatched content, as expected).
Your environment
- Public source code: no
- Is this a consumer or provider issue? Do you have information about the other side?: provider
- Pact Python version used:
pip list | grep pact: pact-python 2.3.1 - Information about your Pact broker (version, hosted where, pactflow, ...): N/A
- Operating system and version (e.g. Ubuntu 20.04.2 LTS, macOS Ventura): Debian GNU/Linux 12 (bookworm)
Self-service
- I'd be willing to fix this bug myself.
- Lenguaje dominante
- Python
- Estrellas
- 685
- Forks
- 147
- Merge medio
- 4 d 8 h
- PR fusionados (30 d)
- 14
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de pact-foundation/pact-python
-
Add `abi3t` WheelsAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
pact-foundation/pact-python#1603 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Post v3 tracking issueQuizá libre de nuevo @JP-Ellis la tomó hace 375 días y no hay ningún pull request abierto. Abiertotype:tracking
pact-foundation/pact-python#1272 · 1 asignado ·
Los mantenedores suelen responder en 2 días
-
area:documentation difficulty:easy type:chore
Dificultad 3/5 1-2 días Aptitud para principiantes 48/100
pact-foundation/pact-python#1267 ·
Los mantenedores suelen responder en 2 días
-
Create message Pact docsAbiertoarea:documentation difficulty:easy type:chore
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
pact-foundation/pact-python#1266 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
-
Add a complete gRPC examplePosiblemente ocupada @JP-Ellis la tomó hace 477 días. Abiertoarea:core area:documentation area:examples difficulty:medium smartbear-supported type:chore
pact-foundation/pact-python#1092 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 2 días
Todos los issues de pact-foundation/pact-python
Issues similares
-
area:core-platform effort:S priority:P3 status:in-review type:test
Dificultad 2/5 Menos de una hora Aptitud para principiantes 80/100
randomparity/kdive#3246 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Requantification library converts m/z to mass with the hydrogen-atom mass instead of the proton massAbiertobug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
nf-core/metaboigniter#130 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
common-workflow-language/cwl-utils#477 ·
Los mantenedores suelen responder en 1 día
-
Add dependabotAbiertofeat
Dificultad 2/5 Menos de una hora Aptitud para principiantes 72/100
open-nudge/opentemplate#204 ·
Los mantenedores suelen responder en 1 día
-
github-stale-ci-pr-closer: KV state is double-wrapped, never persists, and hits the depth-32 limitPosiblemente ocupada @VascoSch92 la tomó hoy. Abiertopriority:medium ready-for-dev
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
OpenHands/extensions#781 ·
Los mantenedores suelen responder en 1 día