From 4b4d4468b02eb1eead4526418cc5852b885582a7 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Mon, 10 Feb 2025 16:09:22 +0100 Subject: [PATCH] Enrichi l'objet erreur retour --- api/views/purchaseimport.py | 1 + common/api/validata.py | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/api/views/purchaseimport.py b/api/views/purchaseimport.py index 8233773bb..f6f248e9f 100644 --- a/api/views/purchaseimport.py +++ b/api/views/purchaseimport.py @@ -67,6 +67,7 @@ def post(self, request): # Step 2: Schema validation (Validata) report = validate_file_against_schema(self.file, self.schema_url) + print(report["tasks"][0]["errors"]) self.errors = process_errors(report) if len(self.errors): self._log_error("Echec lors de la validation du fichier (schema achats.json - Validata)") diff --git a/common/api/validata.py b/common/api/validata.py index b1903d4b8..2e3b45025 100644 --- a/common/api/validata.py +++ b/common/api/validata.py @@ -19,11 +19,15 @@ def process_errors(report): for error in report["tasks"][0]["errors"]: errors.append( { - "row": error["rowNumber"], - "status": 400, - "column": error["fieldName"], + # cells, description, fieldNumber, name, note, rowNumber, tags, type + "row": error["rowPosition"], + "column": error["fieldPosition"], + "field": error["fieldName"], "cell": error["cell"], + "title": error["title"], "message": error["message"], + "code": error["code"], + "status": 400, } ) return errors