Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions geonode/upload/handlers/xlsx/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The generic except Exception block will catch all exceptions, including InvalidInputFileException instances raised earlier in the try block (e.g., from _validate_sheets, _validate_headers, or when the file is empty). This causes specific validation error messages to be replaced by the generic "Failed to securely parse Excel." message, which will cause existing tests like test_pre_processing_fails_on_missing_lat and test_pre_processing_fails_on_wrong_data to fail.

To preserve helpful validation feedback while still preventing information exposure from unexpected internal errors, catch InvalidInputFileException separately and re-raise it.

Suggested change
except Exception:
except InvalidInputFileException:
raise
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
Expand Down
Loading