diff --git a/.github/assets/badges/package.svg b/.github/assets/badges/package.svg
index d33b931..c282f82 100644
--- a/.github/assets/badges/package.svg
+++ b/.github/assets/badges/package.svg
@@ -1 +1 @@
-
+
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a4d4c99..a650d1f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -20,6 +20,17 @@ jobs:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
+ - name: Setup Python for dependency audit
+ uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v5
+ with:
+ python-version: "3.11"
+
+ - name: Install dependency auditor
+ run: |
+ python -m venv "$RUNNER_TEMP/pip-audit"
+ "$RUNNER_TEMP/pip-audit/bin/python" -m pip install --upgrade pip "setuptools>=84.1.0"
+ "$RUNNER_TEMP/pip-audit/bin/python" -m pip install pip-audit "filelock>=4.2.1"
+
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v5
with:
@@ -28,7 +39,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip "setuptools>=83.0.0"
- python -m pip install requests pylint isort pip-audit
+ python -m pip install requests pylint isort
python -m pip install -e .
- name: Lint with Pylint
@@ -43,7 +54,9 @@ jobs:
run: python -m unittest discover tests/
- name: Dependency audit
- run: pip-audit
+ run: |
+ "$RUNNER_TEMP/pip-audit/bin/pip-audit" --path "$(python -c 'import sysconfig; print(sysconfig.get_path("purelib"))')"
+ "$RUNNER_TEMP/pip-audit/bin/pip-audit"
- name: Dependency review
if: github.event_name == 'pull_request'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5229024..1b43952 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
This project follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [3.6.1] - 2026-11-13
+
+### Fixed
+- Preserve API error details when the response has no top-level message.
+
## [3.6.0] - 2026-08-27
### Added
diff --git a/mercadopago/config/config.py b/mercadopago/config/config.py
index 9cf961a..514b1a1 100644
--- a/mercadopago/config/config.py
+++ b/mercadopago/config/config.py
@@ -26,7 +26,7 @@ class Config:
def __init__(self):
"""Builds version-dependent values (user_agent, tracking_id)."""
- self.__version = "3.6.0"
+ self.__version = "3.6.1"
self.__user_agent = "MercadoPago Python SDK v" + self.__version
self.__product_id = "bc32bpftrpp001u8nhlg"
self.__tracking_id = "platform:" + platform.python_version()
diff --git a/mercadopago/errors/exceptions.py b/mercadopago/errors/exceptions.py
index 2248614..41c65f2 100644
--- a/mercadopago/errors/exceptions.py
+++ b/mercadopago/errors/exceptions.py
@@ -5,6 +5,8 @@
per HTTP status code.
"""
+import json
+
class MercadoPagoError(Exception):
"""Base exception for all MercadoPago API errors.
@@ -15,18 +17,29 @@ class MercadoPagoError(Exception):
Attributes:
status_code: HTTP status code (e.g. 400, 401, 500).
- message: Human-readable error summary from the API.
- error: Machine-readable error code (e.g. ``"unauthorized"``).
+ message: API message, or serialized response body if absent.
+ error: API message, or serialized response body if absent.
causes: List of detailed cause dicts returned by the API.
request_id: ``x-request-id`` header for support diagnosis.
"""
def __init__(self, status_code, response_body):
self.status_code = status_code
- self.response = response_body or {}
- self.message = self.response.get("message", "")
- self.error = self.response.get("error", "")
- self.causes = self.response.get("cause", [])
+ self.response = response_body if response_body is not None else {}
+ body = self.response if isinstance(self.response, dict) else {}
+ message = body.get("message")
+ if isinstance(message, str) and message.strip():
+ error_value = message
+ else:
+ try:
+ serialized_body = json.dumps(self.response, ensure_ascii=False)
+ error_value = serialized_body if serialized_body != "{}" else ""
+ except (TypeError, ValueError, OverflowError, RecursionError):
+ error_value = ""
+ error_value = error_value or f"HTTP {status_code or 0}"
+ self.message = error_value
+ self.error = error_value
+ self.causes = body.get("cause", [])
self.request_id = None # set by MPResponse if x-request-id header is available
super().__init__(f"[{status_code}] {self.message or self.error}")
diff --git a/mercadopago/errors/response.py b/mercadopago/errors/response.py
index 02bdc71..2e6c39e 100644
--- a/mercadopago/errors/response.py
+++ b/mercadopago/errors/response.py
@@ -58,10 +58,14 @@ def is_success(self):
@property
def error_message(self):
- """Human-readable error message from the API body, or empty string."""
+ """API message or a useful error fallback for unsuccessful responses."""
body = self.get("response") or {}
if isinstance(body, dict):
- return body.get("message", "")
+ message = body.get("message", "")
+ if isinstance(message, str) and message.strip():
+ return message
+ if not self.is_success:
+ return build_error(self.status_code, body).error
return ""
@property
diff --git a/pyproject.toml b/pyproject.toml
index 1e14e47..a3e3696 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "mercadopago"
-version = "3.6.0"
+version = "3.6.1"
authors = [
{name = "Mercado Pago", email = "mp_sdk@mercadopago.com"}
]