From fcbe08fc1fead0c657f104d755ab6ca57fa77d02 Mon Sep 17 00:00:00 2001 From: Giovanni Allegri Date: Tue, 14 Apr 2026 11:20:36 +0200 Subject: [PATCH 1/4] Fix exception handling for XLSX Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- geonode/upload/handlers/xlsx/handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/geonode/upload/handlers/xlsx/handler.py b/geonode/upload/handlers/xlsx/handler.py index d44e99cb586..9bef554c47d 100644 --- a/geonode/upload/handlers/xlsx/handler.py +++ b/geonode/upload/handlers/xlsx/handler.py @@ -213,9 +213,9 @@ def pre_processing(self, files, execution_id, **kwargs): # Note: rows_gen continues from the row after the headers self._convert_to_csv(headers, rows_gen, output_file) - except Exception as e: + except Exception: logger.exception("XLSX Pre-processing failed") - raise InvalidInputFileException(detail=f"Failed to securely parse Excel: {str(e)}") + raise InvalidInputFileException(detail="Failed to securely parse Excel.") # update the file path in the payload _data["files"]["base_file"] = output_file From 0d88790ba427b193764bc69f5abc3427d545f630 Mon Sep 17 00:00:00 2001 From: Giovanni Allegri Date: Tue, 14 Apr 2026 11:22:16 +0200 Subject: [PATCH 2/4] Enhance error logging in XLSX handler Improved error logging for XLSX pre-processing failure. --- geonode/upload/handlers/xlsx/handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geonode/upload/handlers/xlsx/handler.py b/geonode/upload/handlers/xlsx/handler.py index 9bef554c47d..5232c598d03 100644 --- a/geonode/upload/handlers/xlsx/handler.py +++ b/geonode/upload/handlers/xlsx/handler.py @@ -214,7 +214,7 @@ def pre_processing(self, files, execution_id, **kwargs): self._convert_to_csv(headers, rows_gen, output_file) except Exception: - logger.exception("XLSX Pre-processing failed") + logger.exception(f"XLSX Pre-processing failed: {str(e)}") raise InvalidInputFileException(detail="Failed to securely parse Excel.") # update the file path in the payload From 474178be40106e4eee6a3882917a221877acc024 Mon Sep 17 00:00:00 2001 From: Giovanni Allegri Date: Tue, 14 Apr 2026 11:24:03 +0200 Subject: [PATCH 3/4] Log exception details during XLSX processing --- geonode/upload/handlers/xlsx/handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geonode/upload/handlers/xlsx/handler.py b/geonode/upload/handlers/xlsx/handler.py index 5232c598d03..f10563ff485 100644 --- a/geonode/upload/handlers/xlsx/handler.py +++ b/geonode/upload/handlers/xlsx/handler.py @@ -213,7 +213,7 @@ def pre_processing(self, files, execution_id, **kwargs): # Note: rows_gen continues from the row after the headers self._convert_to_csv(headers, rows_gen, output_file) - except Exception: + except Exception as e: logger.exception(f"XLSX Pre-processing failed: {str(e)}") raise InvalidInputFileException(detail="Failed to securely parse Excel.") From 11a3db86ae224916b8a4ae32410488f673a232de Mon Sep 17 00:00:00 2001 From: "G.Allegri" Date: Wed, 17 Jun 2026 17:41:45 +0000 Subject: [PATCH 4/4] Fixed exception handling --- geonode/upload/handlers/xlsx/handler.py | 8 ++++++-- geonode/upload/handlers/xlsx/tests.py | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/geonode/upload/handlers/xlsx/handler.py b/geonode/upload/handlers/xlsx/handler.py index 867f0e6c427..c6e3abf59cf 100644 --- a/geonode/upload/handlers/xlsx/handler.py +++ b/geonode/upload/handlers/xlsx/handler.py @@ -236,9 +236,13 @@ def pre_processing(self, files, execution_id, **kwargs): # Note: rows_gen continues from the row after the headers self._convert_to_csv(headers, rows_gen, output_file) + except InvalidInputFileException as e: + logger.exception(f"XLSX Pre-processing failed: {e}") + raise + except Exception as e: - logger.exception(f"XLSX Pre-processing failed: {str(e)}") - raise InvalidInputFileException(detail="Failed to securely parse Excel.") + logger.exception(f"XLSX Pre-processing failed: {e}") + raise InvalidInputFileException(detail="Failed to parse Excel.") # update the file path in the payload _data["files"]["base_file"] = output_file diff --git a/geonode/upload/handlers/xlsx/tests.py b/geonode/upload/handlers/xlsx/tests.py index fb432f799b0..6eafb1334d4 100644 --- a/geonode/upload/handlers/xlsx/tests.py +++ b/geonode/upload/handlers/xlsx/tests.py @@ -80,7 +80,6 @@ def test_pre_processing_fails_on_missing_lat(self, mock_get_exec): ): with self.assertRaises(InvalidInputFileException) as context: self.handler.pre_processing(files, exec_id) - self.assertIn("geometry headers", str(context.exception)) @patch("geonode.upload.orchestrator.orchestrator.get_execution_object") @@ -158,7 +157,7 @@ def test_security_billion_laughs_protection(self): with self.assertRaises(InvalidInputFileException) as context: self.handler.pre_processing(files, exec_id) - self.assertIn("Failed to securely parse Excel", str(context.exception)) + self.assertIn("Failed to parse Excel", str(context.exception)) finally: if os.path.exists(malicious_path): os.remove(malicious_path)