Conversation
…ateway proxy Replace the repeated try/except (HTTPException, OSError) blocks in the periodic-tasks and task-history proxy routes with a single reraise_upstream_tasks_errors() context manager, keeping the SEP gateway error contract in one place. Add unit tests covering clean blocks, client-error passthrough, server-error/OSError -> 502 mapping, and unrelated-exception propagation.
marcuscruz-percona
requested review from
peter-o-addo and
yyyyyyyan
as code owners
July 14, 2026 18:25
Contributor
There was a problem hiding this comment.
Pull request overview
This PR centralizes SEP→Tasks gateway error handling by introducing a shared reraise_upstream_tasks_errors() context manager and updating the periodic-tasks and task-history proxy routes to use it, keeping the proxy error contract consistent across endpoints.
Changes:
- Add
reraise_upstream_tasks_errors()context manager inapp/sep/api/proxy.pyto wrap upstream Tasks API calls and apply the existing mapping rules. - Replace repeated
try/except (HTTPException, OSError)blocks in periodic-tasks and task-history routes with the new context manager. - Add unit tests covering the context manager’s behavior for clean blocks, upstream client/server errors,
OSError, and unrelated exceptions.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
app/sep/api/proxy.py |
Adds a context manager wrapper for the existing upstream error-mapping helper. |
app/sep/api/routes/task_history.py |
Switches proxy calls to use the shared context manager instead of inline try/except blocks. |
app/sep/api/routes/periodic_tasks.py |
Switches proxy calls to use the shared context manager instead of inline try/except blocks. |
tests/app/sep/api/test_proxy.py |
Adds focused unit tests for the new context manager behavior. |
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
yyyyyyyan
approved these changes
Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
try/except (HTTPException, OSError)blocks across the periodic-tasks and task-history proxy routes with a singlereraise_upstream_tasks_errors()context manager, keeping the SEP→Tasks gateway error contract in one place.OSErrors map to 502.Tested
pytest tests/app/sep/api/test_proxy.py -v— new unit tests greenChecklist
make test)make run-pre-commit)make makemigrations)changelog.d/if the change is user-facing (make changelog-add), or confirmed N/A (internal-only change, or a same-release-cycle fix for an unreleased sibling ticket)