From 549d4c1a20ebcf0ef93aede907445f2e50271cda Mon Sep 17 00:00:00 2001 From: Raphael Cohen Date: Tue, 26 Sep 2023 15:21:32 +0200 Subject: [PATCH] feat: Improve message when data storage is not reachable --- CHANGELOG.md | 4 ++++ sekoia_automation/module.py | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13bd486..ba52316 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Improve error message when it is not possible to access the data storage + ## [1.5.0] - 2023-09-19 ### Added diff --git a/sekoia_automation/module.py b/sekoia_automation/module.py index 76a0e8d..ece91b6 100644 --- a/sekoia_automation/module.py +++ b/sekoia_automation/module.py @@ -8,6 +8,7 @@ import requests import sentry_sdk +from botocore.exceptions import ClientError from pydantic import BaseModel from requests import HTTPError, Response @@ -350,8 +351,14 @@ def _ensure_data_path_set(self): try: self._data_path = get_data_path() except Exception as e: + if ( + isinstance(e, ClientError) + and e.response.get("Error", {}).get("Code") == "403" + ): + self.log("Access denied to the object storage", level="critical") + raise self.log_exception(e) - self.log("Impossible to get the data path", level="critical") + self.log("Impossible access the object storage", level="critical") raise def log(