app: replace broad exception handling that hides errors #64

Open
opened 2026-10-06 13:55:49 +00:00 by ffrauenberger · 1 comment
Owner

Severity: improvement (low to medium)

Where

  • app/__main__.py:41-44
  • app/io_operations/export_operations.py:129-146
  • app/mining_algorithms/inductive_mining_infrequent.py:277-304, :466-477
  • app/ui/base_algorithm_ui/base_algorithm_controller.py:253-260
  • app/ui/genetic_miner_ui/genetic_miner_controller.py:190-194
  • app/ui/home_ui/home_controller.py:289-296, :313-322

Problem

Location Issue
app/mining_algorithms/inductive_mining_infrequent.py:277-304 except Exception around the whole filtered cut detection. Any programming error is logged and the algorithm silently falls back to a flower model, so users get a "valid" but meaningless model.
app/mining_algorithms/inductive_mining_infrequent.py:466-477 _preserve_start_end_nodes guards with hasattr and except Exception and only logs at debug level. If it fails, the filtered DFG has no start/end nodes and the cuts are wrong without notice.
app/io_operations/export_operations.py:129-146 Re-raises every error as a bare Exception(f"Failed …"), losing the type and traceback (raise … from e is missing), and leaks the temp file.
app/ui/home_ui/home_controller.py:289-296, :313-322 except Exception turns any failure into "auto-detect ," or "no columns" without telling the user.
app/ui/genetic_miner_ui/genetic_miner_controller.py:190-194 Any exception is reported as "use a population size of at least 3".
app/__main__.py:41-44 Configuration errors are printed instead of logged, then ignored.
app/ui/base_algorithm_ui/base_algorithm_controller.py:253-260 See #8.

Related: #8.

Fix

  • Catch specific exceptions
  • Chain re-raised exceptions with raise … from e
  • Log with logger.exception
  • Show the user a message that names the real cause

from issues/CQ-002-broad-exception-handling-and-swallowed-errors.md (code analysis of commit 6bcc646, 2026-10-03)

**Severity:** improvement (low to medium) ## Where - `app/__main__.py:41-44` - `app/io_operations/export_operations.py:129-146` - `app/mining_algorithms/inductive_mining_infrequent.py:277-304`, `:466-477` - `app/ui/base_algorithm_ui/base_algorithm_controller.py:253-260` - `app/ui/genetic_miner_ui/genetic_miner_controller.py:190-194` - `app/ui/home_ui/home_controller.py:289-296`, `:313-322` ## Problem | Location | Issue | |---|---| | `app/mining_algorithms/inductive_mining_infrequent.py:277-304` | `except Exception` around the whole filtered cut detection. Any programming error is logged and the algorithm silently falls back to a flower model, so users get a "valid" but meaningless model. | | `app/mining_algorithms/inductive_mining_infrequent.py:466-477` | `_preserve_start_end_nodes` guards with `hasattr` and `except Exception` and only logs at debug level. If it fails, the filtered DFG has no start/end nodes and the cuts are wrong without notice. | | `app/io_operations/export_operations.py:129-146` | Re-raises every error as a bare `Exception(f"Failed …")`, losing the type and traceback (`raise … from e` is missing), and leaks the temp file. | | `app/ui/home_ui/home_controller.py:289-296`, `:313-322` | `except Exception` turns any failure into "auto-detect `,`" or "no columns" without telling the user. | | `app/ui/genetic_miner_ui/genetic_miner_controller.py:190-194` | Any exception is reported as *"use a population size of at least 3"*. | | `app/__main__.py:41-44` | Configuration errors are `print`ed instead of logged, then ignored. | | `app/ui/base_algorithm_ui/base_algorithm_controller.py:253-260` | See #8. | Related: #8. ## Fix - Catch specific exceptions - Chain re-raised exceptions with `raise … from e` - Log with `logger.exception` - Show the user a message that names the real cause --- from `issues/CQ-002-broad-exception-handling-and-swallowed-errors.md` (code analysis of commit 6bcc646, 2026-10-03)
Author
Owner

Reviewed by Codex (GPT-6) against origin/main 6bcc646eb464.

Review: partially correct.

The broad-catch and cleanup concerns are supported, but “losing the type and traceback because raise ... from e is missing” is only partly correct. Raising a new exception inside except automatically retains the original exception in __context__, and standard traceback rendering includes it. Reproduced the export wrapper with a missing temp-directory key: the new Exception retains the original AttributeError as its context, although __cause__ is unset. The top-level exception type is replaced and explicit from e would express causality more clearly; the original traceback is not discarded. Temp-file leakage applies to failures after a file has been created, not every caught error.

Code references: app/io_operations/export_operations.py:145, app/mining_algorithms/inductive_mining_infrequent.py:301.

Reviewed by **Codex (GPT-6)** against origin/main [`6bcc646eb464`](https://code.swisdata.eu/ffrauenberger/ProcessIntel/commit/6bcc646eb464e0dd897228b5e49867f65d7255c4). **Review: partially correct.** The broad-catch and cleanup concerns are supported, but “losing the type and traceback because `raise ... from e` is missing” is only partly correct. Raising a new exception inside `except` automatically retains the original exception in `__context__`, and standard traceback rendering includes it. Reproduced the export wrapper with a missing temp-directory key: the new `Exception` retains the original `AttributeError` as its context, although `__cause__` is unset. The top-level exception **type** is replaced and explicit `from e` would express causality more clearly; the original traceback is not discarded. Temp-file leakage applies to failures after a file has been created, not every caught error. Code references: [app/io_operations/export_operations.py:145](https://code.swisdata.eu/ffrauenberger/ProcessIntel/src/commit/6bcc646eb464e0dd897228b5e49867f65d7255c4/app/io_operations/export_operations.py#L145), [app/mining_algorithms/inductive_mining_infrequent.py:301](https://code.swisdata.eu/ffrauenberger/ProcessIntel/src/commit/6bcc646eb464e0dd897228b5e49867f65d7255c4/app/mining_algorithms/inductive_mining_infrequent.py#L301).
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ffrauenberger/ProcessIntel#64
No description provided.