chore(logging): disable traceback for controlled exceptions#52
Open
gkostkowski wants to merge 3 commits into
Open
chore(logging): disable traceback for controlled exceptions#52gkostkowski wants to merge 3 commits into
gkostkowski wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts service-layer logging so controlled resolution failures in EntityResolutionService.process_request are emitted as single-line ERROR logs without Python tracebacks, while keeping traceback logging at higher-level entrypoints for unexpected failures.
Changes:
- Replaced
log.exception(...)withlog.error(...)inEntityResolutionService.process_requestto suppress tracebacks during resolution failures. - Expanded the error log message to include the exception message inline.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+491
to
+495
| except Exception as exc: # pylint: disable=broad-exception-caught | ||
| log.exception( | ||
| "Resolution error for mention %s", | ||
| log.error( | ||
| "Resolution error for mention %s: %s", | ||
| request.ere_request_id, | ||
| exc, |
45a493f to
c6eadff
Compare
Controlled exceptions (ValueError, ConflictError) are logged with log.error (no traceback, typed response). Uncontrolled exceptions are caught as fallback with log.exception (full traceback, generic InternalError response). Adds top-level ConflictError import.
c6eadff to
88b97f9
Compare
|
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.



This change addresses TEDSWS-534 Another case of an uncontrolled exception and TEDSWS-529 The ERE throws an exception then the ERS sends an entity of an non-configured type.
Summary
Replace the single
log.exceptioninEntityResolutionService.process_requestwith a two-tier catch:ValueError,ConflictError): logged vialog.error— single line, no traceback, typedEREErrorResponsewith actual error type and message.log.exception— full traceback retained, genericEREErrorResponse(InternalError) that does not leak internal details.Top-level entrypoint catches (
app.py,queue_worker.py) remain unchanged.Before
After
Controlled (no traceback):
Uncontrolled — crafted/hypothetical example to illustrate the fallback behavior (traceback retained):