fix(persistence): close session in AutomationProfileRepository auto_commit finally block #1173

Merged
freemo merged 1 commits from bugfix/m5-automation-profile-session-leak into master 2026-04-04 19:58:55 +00:00

1 Commits

Author SHA1 Message Date
Luis Mendes 9e93ea5fc6 fix(persistence): close session in AutomationProfileRepository auto_commit finally block
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Failing after 20s
CI / helm (pull_request) Successful in 22s
CI / build (pull_request) Successful in 37s
CI / quality (pull_request) Successful in 3m43s
CI / typecheck (pull_request) Successful in 4m0s
CI / security (pull_request) Successful in 4m6s
CI / coverage (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Has been skipped
CI / unit_tests (pull_request) Failing after 6m50s
CI / docker (pull_request) Has been skipped
CI / e2e_tests (pull_request) Failing after 13m38s
CI / integration_tests (pull_request) Failing after 22m40s
CI / status-check (pull_request) Failing after 1s
Add missing `finally: if self._auto_commit: session.close()` blocks to
all four public session-creating methods in `AutomationProfileRepository`:
`get_by_name()`, `list_all()`, `upsert()`, and `delete()`.  Without
these blocks, sessions were never closed when the repository operated in
auto_commit mode, causing a slow session leak that could exhaust the
connection pool over time.

The fix mirrors the pattern already used by `SessionRepository`, which
correctly closes its session in a `finally` block for every public method.

Removed the `@tdd_expected_fail` tag from the TDD test
(`tdd_automation_profile_session_leak.feature`) so the six scenarios
now run as normal regression tests (four original plus two new scenarios
for `get_by_name` and `list_all`).

ISSUES CLOSED: #987
2026-04-03 19:00:22 +00:00