-
[OPIK-4324] [BE] fix: keep react-service auth errors as client errors when the body is not JSON (#7625)
发布于
2026-07-29 08:58:10 +00:00 - [OPIK-4324] [BE] fix: keep react-service auth errors as client errors when the body is not JSON
verifyResponse read 401/400 react-service replies as ReactServiceErrorResponse
unconditionally. Endpoints guarded by Dropwizard's @Auth filter answer an
expired session cookie with a text/plain 401, so Jersey raised
MessageBodyProviderNotFoundException — a ProcessingException that escapes
AuthFilter and surfaces as a 500 instead of the intended 401.Read the error message only when the body is actually JSON; otherwise log the
raw body and fall back to a caller-facing default. Duplicate of OPIK_1606.Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
- [OPIK-4324] [BE] fix: buffer react-service error entity and address review feedback
- Buffer the response entity before reading it, so the error path is reliable
against multiple reads instead of only checking that an entity exists. Lets the
JSON-parse recovery path log the raw body, which previously came out empty. - Null-check the deserialized ReactServiceErrorResponse alongside the blank-msg
check. - Log the full exception rather than just its message, and quote all printed
values and move them to the end of the sentence for easier grepping. - Reword the workspace lookup log message.
Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
- [OPIK-4324] [BE] fix: cap logged remote bodies and lower expected-400 log level
- Cap the remote body read for diagnostics at 512 characters. A remote error body
is arbitrary upstream content (a proxy error page or a stack trace, not
necessarily our own JSON), so it must not flood the logs or carry an unbounded
amount of upstream detail into them. - An unknown workspace name on the public-endpoint fallback path is a caller
mistake, not a server fault, so log it at WARN instead of ERROR.
Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
- [OPIK-4324] [BE] fix: guard every readEntity on the buffer result
Fold hasEntity + bufferEntity into isEntityReadable, returning the boolean from
bufferEntity and false on failure, so every readEntity call is guarded by both
checks together rather than only by hasEntity. An already buffered entity reports
success, so the diagnostic re-read still works.Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
- [OPIK-4324] [BE] fix: do not drop remote message for +json and text/json bodies
Gating on APPLICATION_JSON_TYPE.isCompatible was stricter than the registered
Jackson provider: application/problem+json and text/json deserialize fine, so a
real ReactServiceErrorResponse message that used to reach the caller was being
replaced by the fallback. Match what Jackson parses instead — subtype json or a
+json structured suffix — while still treating a wildcard or absent type as
non-JSON, since neither says anything about the body.Add a content-type matrix test so the set of types read as JSON stays pinned.
Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
- [OPIK-4324] [BE] fix: never trust a wildcard content type, clarify matrix test name
- isJson rejects any subtype containing a wildcard, not just the bare '', so
application/+json is no longer trusted on the strength of its suffix. A
wildcard is not a legal response content type, so it says nothing about the
body, and accepting it was inconsistent with rejecting / and application/*. - Rename the matrix test to thenJsonSubtypesSurfaceRemoteMessage: the contract it
asserts is subtype json or a +json suffix, which is wider than the old
"OnlyJsonContentTypes" wording implied.
Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
- [OPIK-4324] [BE] test: drop the test* prefix from the tests added here
testing.md lists void testCreateUser() as a bad name, and the repo agrees: 4354
test methods carry no prefix against 280 that do, with 1185 already using this
exact subject__whenX__thenY shape. Rename the five tests added by this PR to
match. The 17 pre-existing test*-prefixed methods in this class are left alone —
renaming them is unrelated to this fix.Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
Co-authored-by: Claude Opus 5 (1M context) noreply@anthropic.com
下载附件