Skip to content

fix(exception): log 4xx at WARN without a stack trace, keep ERROR for 5xx. CU-17tkuw5vn1y - #2887

Merged
aliaska-varieva merged 1 commit into
mainfrom
fix/exception-4xx-warn
Oct 29, 2026
Merged

aliaska-varieva merged 1 commit into
mainfrom
fix/exception-4xx-warn

Conversation

@aliaska-varieva

@aliaska-varieva aliaska-varieva commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem

BaseGlobalExceptionHandler logs every BaseException at ERROR with a full stack trace, including 4xx ones (NotFoundException, BadRequestException, conflicts). Missing header, method-not-supported and media-type errors are logged the same way.

A caller asking for an unknown id therefore shows up in logs and alerts as a server fault. Example on prod (openframe-saas-management-api): NOT_FOUND: Device … not found logged at ERROR with its stack trace.

Fix

Case Before After
BaseException, 4xx ERROR + stack WARN, message only
BaseException, 5xx ERROR + stack ERROR + stack (unchanged)
Missing header (400) ERROR + stack WARN, header name
Method not supported (405), media type not supported (415) ERROR + stack WARN, message only
IllegalArgumentException (400) ERROR + stack WARN + stack (our own code throws it too, e.g. a bad UUID in stored data)

Response bodies and statuses are unchanged; only log levels change.

Tests

  • New BaseGlobalExceptionHandlerLoggingTest (the module's first tests) checks level and stack trace per case.
  • openframe-external-api-service-core GlobalExceptionHandlerTest still passes (20).

Follow-up

After the lib release and bump, the NotFoundException handler added in openframe-saas-shared#2782 (management-api) duplicates this and can be removed.

Change-Set: exception-4xx-warn

Change set flamingo-stack/exception-4xx-warn: this pull request is the only one in it so far. Another pull request joins by naming this one in a Depends-On line, or by carrying the same Change-Set line.

Linked work

  • …and 1 linked item not shown here

Linked by the Depends-On / Change-Set lines in these descriptions; this block is maintained by the hub.

… 5xx. CU-17tkuw5vn1y

BaseGlobalExceptionHandler logged every BaseException (not found, bad
request, conflict) and missing header / method / media type errors at
ERROR with a full stack trace, so a caller's typo looked like a server
fault and flooded the logs.

- BaseException: 5xx -> ERROR with stack trace, anything else -> WARN
  with the message only
- missing header, method not supported, media type not supported:
  WARN with the message only
- IllegalArgumentException (400): WARN, stack trace kept because our own
  code throws it too (bad UUID or number in stored data)
- first tests for the module (spring-boot-starter-test, test scope)
@github-actions

Copy link
Copy Markdown
Contributor

🦩 Flamingo Code Review

Not reviewed yet. Reviews start when you ask, so the reviewer reads this pull request when it is ready, not when it is opened.

When it is ready:

  • Review this pull request

Or comment @flamingo-review. Add the flamingo-review-always label to review every push.

Updated 2026-10-29 19:39 UTC · workflow run

@aliaska-varieva
aliaska-varieva added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit ddce782 Oct 29, 2026
21 checks passed
@aliaska-varieva
aliaska-varieva deleted the fix/exception-4xx-warn branch October 29, 2026 19:54
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