From ea774116431a1369d45044106ab8371563849417 Mon Sep 17 00:00:00 2001 From: Mikhail Yohman Date: Thu, 3 Apr 2025 16:28:03 -0600 Subject: [PATCH 1/3] Update repository/documentation links for packaging/publishing --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index bc262f4..bfe45a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,8 +6,8 @@ authors = ["OpsMill "] readme = "README.md" license = "Apache-2.0" homepage = "https://opsmill.com" -repository = "https://github.com/opsmill/infrahub" -documentation = "https://docs.infrahub.app/python-sdk/" +repository = "https://github.com/opsmill/infrahub-sdk-python" +documentation = "https://docs.infrahub.app/python-sdk/introduction" packages = [{ include = "infrahub_sdk" }] classifiers = [ "Intended Audience :: Developers", From 4b0244c7cb0f4b1eb79a9236827d7aa4ef4a8472 Mon Sep 17 00:00:00 2001 From: Damien Garros Date: Fri, 4 Apr 2025 09:22:54 +0200 Subject: [PATCH 2/3] Improve error message when a schema is not JSON valid. --- changelog/+jsondecode.changed.md | 1 + infrahub_sdk/schema/__init__.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changelog/+jsondecode.changed.md diff --git a/changelog/+jsondecode.changed.md b/changelog/+jsondecode.changed.md new file mode 100644 index 0000000..030c274 --- /dev/null +++ b/changelog/+jsondecode.changed.md @@ -0,0 +1 @@ +Improve error message when a schema received from the server is not JSON valid. The new exception will be of type `infrahub_sdk.exceptions.JsonDecodeError` instead of `json.decoder.JSONDecodeError` \ No newline at end of file diff --git a/infrahub_sdk/schema/__init__.py b/infrahub_sdk/schema/__init__.py index 080d723..3a8773b 100644 --- a/infrahub_sdk/schema/__init__.py +++ b/infrahub_sdk/schema/__init__.py @@ -1,6 +1,7 @@ from __future__ import annotations import asyncio +import json from collections.abc import MutableMapping from enum import Enum from time import sleep @@ -13,6 +14,7 @@ from ..exceptions import ( InvalidResponseError, + JsonDecodeError, SchemaNotFoundError, ValidationError, ) @@ -420,7 +422,14 @@ async def _fetch( response = await self.client._get(url=url, timeout=timeout) response.raise_for_status() - data: MutableMapping[str, Any] = response.json() + try: + data: MutableMapping[str, Any] = response.json() + except json.decoder.JSONDecodeError as exc: + raise JsonDecodeError( + message=f"Invalid Schema response received from the server at {response.url}: {response.text} [{response.status_code}] ", + content=response.text, + url=response.url, + ) from exc nodes: MutableMapping[str, MainSchemaTypesAPI] = {} for node_schema in data.get("nodes", []): From 35852acd1dea34c3687f24b794b550b2ab6ece4d Mon Sep 17 00:00:00 2001 From: Damien Garros Date: Fri, 4 Apr 2025 15:29:42 +0200 Subject: [PATCH 3/3] Prep Release 1.10.1 --- CHANGELOG.md | 6 ++++++ changelog/+jsondecode.changed.md | 1 - pyproject.toml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) delete mode 100644 changelog/+jsondecode.changed.md diff --git a/CHANGELOG.md b/CHANGELOG.md index d4f8a7d..e1cfdc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,12 @@ This project uses [*towncrier*](https://towncrier.readthedocs.io/) and the chang +## [1.9.1](https://github.com/opsmill/infrahub-sdk-python/tree/v1.9.1) - 2025-04-04 + +### Changed + +- Improve error message when a schema received from the server is not JSON valid. The new exception will be of type `infrahub_sdk.exceptions.JsonDecodeError` instead of `json.decoder.JSONDecodeError` + ## [1.10.0](https://github.com/opsmill/infrahub-sdk-python/tree/v1.10.0) - 2025-04-01 ### Deprecated diff --git a/changelog/+jsondecode.changed.md b/changelog/+jsondecode.changed.md deleted file mode 100644 index 030c274..0000000 --- a/changelog/+jsondecode.changed.md +++ /dev/null @@ -1 +0,0 @@ -Improve error message when a schema received from the server is not JSON valid. The new exception will be of type `infrahub_sdk.exceptions.JsonDecodeError` instead of `json.decoder.JSONDecodeError` \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index bfe45a8..f51be0a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "infrahub-sdk" -version = "1.10.0" +version = "1.10.1" description = "Python Client to interact with Infrahub" authors = ["OpsMill "] readme = "README.md"