Skip to content

Fiddle: tidy up exception handling in api and message processor#128

Merged
krishan711 merged 2 commits into
mainfrom
tidymessagerror
Jan 23, 2026
Merged

Fiddle: tidy up exception handling in api and message processor#128
krishan711 merged 2 commits into
mainfrom
tidymessagerror

Conversation

@krishan711
Copy link
Copy Markdown
Contributor

Description

Screenshots:

Checklist:

  • I have updated the CHANGELOG with a summary of my changes

Copilot AI review requested due to automatic review settings January 23, 2026 08:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refines exception handling for both background message processing and the HTTP API middleware to provide more structured error information and configurable logging of client errors.

Changes:

  • In MessageQueueProcessor._process_message, wrap arbitrary exceptions with KibaException.from_exception and send only the normalized kibaException.message in notification payloads.
  • In ExceptionHandlingMiddleware, add a configurable shouldSquashClientExceptions flag and corresponding __init__, allowing toggling between squashed error logs and full stack traces for ClientExceptions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
core/queues/message_queue_processor.py Normalizes caught exceptions to KibaException before notifying clients and switches notification content to use the structured exception message.
core/api/middleware/exception_handling_middleware.py Adds an explicit constructor with a shouldSquashClientExceptions toggle and updates ClientException handling to optionally log full stack traces instead of squashed error messages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +34 to +37
if self.shouldSquashClientExceptions:
logging.error(f'{exception.exceptionType} occurred: {exception.message}')
else:
logging.exception(exception)
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The new shouldSquashClientExceptions flag introduces an alternate logging path for ClientException (the else: logging.exception(exception) branch), but there are currently no tests exercising this behavior (e.g. constructing the app with ExceptionHandlingMiddleware(shouldSquashClientExceptions=False) and asserting stack traces are logged / responses unchanged). Consider adding a test case alongside the existing middleware tests (e.g. in tests/api/test_json_route.py or test_streaming_json_route.py) to cover the non-squashed path and guard against regressions in this error-handling behavior.

Copilot uses AI. Check for mistakes.
@krishan711 krishan711 merged commit 0edaed8 into main Jan 23, 2026
4 checks passed
@krishan711 krishan711 deleted the tidymessagerror branch January 23, 2026 08:35
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