Problem
When the upstream annotator returns a response that isn't valid JSON, the proxy can fail with an uncaught exception:
com.eclipsesource.json.ParseException: Expected value at 1:1
The failure occurs in:
BioPortalJSONAnnotationParser.parseAnnotations(...)
... which calls:
Json.parse(queryResponse);
The servlet catches several checked exceptions, but com.eclipsesource.json.ParseException isn't currently handled there, so the exception escapes to Tomcat. Tomcat then logs only the stack trace in localhost.YYYY_MM_DD.log.
Impact
The stack trace doesn't show the upstream HTTP status, upstream URL, content type, or a safe preview of the response body. If application console logs are also discarded by CATALINA_OUT=/dev/null, there isn't enough information to determine whether the upstream service returned HTML, plaintext, an empty body, or another error response.
Expected behavior
If upstream annotator output isn't valid JSON, the proxy should handle that case explicitly and log enough context to diagnose it.
Proposed fix
- Catch
com.eclipsesource.json.ParseException around JSON parsing.
- Log the upstream HTTP status and URL.
- Log a short, bounded preview of the upstream response body.
- Return the proxy's normal error response format instead of allowing the exception to escape to Tomcat.
Acceptance criteria
- Invalid JSON from the upstream annotator doesn't produce an uncaught servlet exception.
- Logs include enough context to identify the upstream response problem.
- Large response bodies are truncated in logs.
- Sensitive request data isn't logged in full.
Problem
When the upstream annotator returns a response that isn't valid JSON, the proxy can fail with an uncaught exception:
The failure occurs in:
... which calls:
The servlet catches several checked exceptions, but
com.eclipsesource.json.ParseExceptionisn't currently handled there, so the exception escapes to Tomcat. Tomcat then logs only the stack trace inlocalhost.YYYY_MM_DD.log.Impact
The stack trace doesn't show the upstream HTTP status, upstream URL, content type, or a safe preview of the response body. If application console logs are also discarded by
CATALINA_OUT=/dev/null, there isn't enough information to determine whether the upstream service returned HTML, plaintext, an empty body, or another error response.Expected behavior
If upstream annotator output isn't valid JSON, the proxy should handle that case explicitly and log enough context to diagnose it.
Proposed fix
com.eclipsesource.json.ParseExceptionaround JSON parsing.Acceptance criteria