diff --git a/geonode/upload/handlers/xlsx/handler.py b/geonode/upload/handlers/xlsx/handler.py index 384a37b324e..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("XLSX Pre-processing failed") - raise InvalidInputFileException(detail=f"Failed to securely parse Excel: {str(e)}") + 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)