Skip to content

feat: actionable error + APP_MEMORY_MB recommendation when a report exceeds the JSON string cap - #800

Merged
NotYuSheng merged 1 commit into
devfrom
feat/report-oom-recommend-memory
Aug 20, 2026
Merged

feat: actionable error + APP_MEMORY_MB recommendation when a report exceeds the JSON string cap#800
NotYuSheng merged 1 commit into
devfrom
feat/report-oom-recommend-memory

Conversation

@NotYuSheng

Copy link
Copy Markdown
Owner

Summary

Follow-up to #793/#792. Even with the raised cap, a report can still exceed it (or exceed the pre-raise default on an unmigrated deployment) — and today that fails as a generic 500 "Report generation failed. Please try again.", with no indication of why or what to do.

  • Backend (GlobalExceptionHandler): handles HttpMessageNotReadableException directly instead of letting it fall into the catch-all. When the cause is a StreamConstraintsException from the string-length cap, parses the attempted size out of Jackson's own exception message and computes a recommended APP_MEMORY_MB by inverting docker-entrypoint.sh's derivation formula (divisor 40, clamp 256MB) — with a distinct message when the request is past that clamp entirely, since no amount of APP_MEMORY_MB would help there. Other malformed-JSON-body cases (unrelated to this cap) now get a proper 400 instead of the same 500 catch-all they silently fell into before.
  • Frontend (AnalysisPage.tsx): reads the structured error and shows an actionable Alert with the attempted size and recommended value, instead of the generic failure text. Had to account for the report request's responseType: 'blob' applying to error bodies too — the error JSON comes back as a Blob, not a parsed object, and has to be read out explicitly. Follows this repo's existing CONTEXT_LENGTH_EXCEEDED pattern (LLM story generator) for structured, actionable error UX.

Test plan

  • GlobalExceptionHandlerTest (new cases): unrelated malformed body → 400; string-length cap → 413 with PAYLOAD_STRING_TOO_LARGE; recommendation math verified against the real reported failure (20,054,016 chars → recommends 1024MB, and independently re-derives that 1024/40 ≥ the attempted size); past-the-hard-ceiling case → recommendedAppMemoryMb is null with the right message. mvn test — 473/474 passing (the one failure is a pre-existing local-environment gap, missing tshark, unrelated to this change).
  • npx tsc --noEmit — clean. npm run build — clean.
  • New Playwright e2e test (llm-error.spec.ts) forcing the 413 via route interception, run against a real rebuilt stack in a real browser — alert renders and is visible with the attempted size and recommended value. (This file specifically exists to catch SGDS Alert rendering null under React 19 when defaultProps aren't restored — real value in testing the actual DOM here, not just TypeScript types.)
  • End-to-end against the real backend (not mocked): rebuilt the stack, POSTed an oversized payload to /api/v1/files/{fileId}/report — got back 413 with attemptedSizeMb: 52, recommendedAppMemoryMb: 2560, confirming the real Jackson exception flows through this new handler correctly.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QDyaaPSRNzNXRzJoS794C4

…xceeds the JSON string cap

Previously, a report request that tripped Jackson's max-string-length cap
(JacksonConfig, #792) fell into GlobalExceptionHandler's catch-all and
surfaced to the user as a generic 500 "Report generation failed. Please
try again." — no indication of what happened or how to fix it.

Backend: GlobalExceptionHandler now handles HttpMessageNotReadableException
directly. When the cause is a StreamConstraintsException from the string-
length cap, it parses the attempted size out of Jackson's own message and
computes a recommended APP_MEMORY_MB by inverting docker-entrypoint.sh's
derivation formula (divisor 40, clamp 256) — with a note when even an
unlimited memory budget wouldn't help, since the derivation clamps at
256MB regardless. Other malformed-body cases now get a proper 400 instead
of falling into the same 500 catch-all.

Frontend: the report-download flow reads this structured error (accounting
for the request's responseType: 'blob', which applies to error bodies too)
and shows an actionable alert with the attempted size and recommended
value, instead of the generic failure message. Follows this repo's
existing CONTEXT_LENGTH_EXCEEDED pattern for the LLM story generator.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDyaaPSRNzNXRzJoS794C4
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5d1713c3-9d43-403e-98d0-f824a164b791

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@NotYuSheng
NotYuSheng merged commit 4aa933d into dev Aug 20, 2026
9 checks passed
@NotYuSheng
NotYuSheng deleted the feat/report-oom-recommend-memory branch August 20, 2026 13:04
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.

1 participant