Skip to content

Fix bare except clauses in trade request exception handling#121

Draft
Copilot wants to merge 2 commits intorefactor_modelsfrom
copilot/sub-pr-116-one-more-time
Draft

Fix bare except clauses in trade request exception handling#121
Copilot wants to merge 2 commits intorefactor_modelsfrom
copilot/sub-pr-116-one-more-time

Conversation

Copy link
Copy Markdown

Copilot AI commented Dec 7, 2025

Addresses code review feedback on PR #116 regarding exception handling anti-patterns.

Two bare except: clauses in the trade request queue view were catching BaseException, which includes system exceptions like KeyboardInterrupt and SystemExit that should propagate.

Changes:

  • timetable/views.py lines 1123, 1158: Changed except: to except Exception: in fallback timetable_slug retrieval blocks
# Before
try:
    trade_request = TradeRequest.objects.get(pk=request_id)
    timetable_slug = trade_request.offered_allocation.timetable.slug
except:  # Catches everything including KeyboardInterrupt
    pass

# After
try:
    trade_request = TradeRequest.objects.get(pk=request_id)
    timetable_slug = trade_request.offered_allocation.timetable.slug
except Exception:  # Only catches normal exceptions
    pass

Both blocks are defensive fallbacks for extracting redirect context when not explicitly provided. The silent failure behavior is intentional - the code continues with a generic redirect if timetable_slug cannot be determined.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Dec 7, 2025
Co-authored-by: Foosec <31885466+Foosec@users.noreply.github.com>
Copilot AI changed the title [WIP] Update based on feedback for model refactor Fix bare except clauses in trade request exception handling Dec 7, 2025
Copilot AI requested a review from Foosec December 7, 2025 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants