From 3cd59c85ebc6caebffd8e31d5a6b7b6b920e9518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Palancher?= Date: Fri, 12 Jul 2024 12:18:38 +0200 Subject: [PATCH] fix(cli): report format unfound error w/ REST API Report error instead of crashing in fatbuildrctl when unable to find format corresponding to a given distribution with fatbuildrweb REST API. fix #172 --- CHANGELOG.md | 2 ++ fatbuildr/protocols/http/client.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 253fb075..3bb56058 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -224,6 +224,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 definition file (#171). - Handle JSON decode error in `fatbuildrctl` in case of unexpected failure in `fatbuildrweb` (#146). +- Report error instead of crashing in `fatbuildrctl` when unable to find format + corresponding to a given distribution with fatbuildrweb REST API (#172). - docs: - Add missing path parameter in REST API to retrieve artifact information. - Add missing optional `architectures` parameter in instances pipelines diff --git a/fatbuildr/protocols/http/client.py b/fatbuildr/protocols/http/client.py index 897cac2c..89e4a0e5 100644 --- a/fatbuildr/protocols/http/client.py +++ b/fatbuildr/protocols/http/client.py @@ -109,6 +109,11 @@ def pipelines_distribution_format(self, distribution): url = f"{self.uri}/pipelines/formats.json?distribution={distribution}" response = self._auth_request(requests.get, url) formats = response.json() + if len(formats) == 0: + raise FatbuildrServerError( + "Unable to find format corresponding to distribution " + f"{distribution}" + ) return list(formats.keys())[0] @check_http_errors