From c3050f9bf56d683455811c0bfe5f422f5b4605f1 Mon Sep 17 00:00:00 2001 From: jo Date: Wed, 3 Jul 2024 13:09:57 +0200 Subject: [PATCH] fix: details are optional in API errors --- hcloud/_client.py | 2 +- tests/unit/test_client.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/hcloud/_client.py b/hcloud/_client.py index 81aabe2..ba01641 100644 --- a/hcloud/_client.py +++ b/hcloud/_client.py @@ -247,7 +247,7 @@ def request( # type: ignore[no-untyped-def] raise APIException( code=error["code"], message=error["message"], - details=error["details"], + details=error.get("details"), trace_id=trace_id, ) diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index b70c142..34f4352 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -110,7 +110,6 @@ def test_request_fails_trace_id(self, client, response): "error": { "code": "conflict", "message": "some conflict", - "details": None, } } ).encode("utf-8")