Skip to content

feat: use custom error servlet to return json rather than default html - #281

Open
rithvik-doshi wants to merge 2197 commits into
devfrom
json-error-servlet
Open

feat: use custom error servlet to return json rather than default html#281
rithvik-doshi wants to merge 2197 commits into
devfrom
json-error-servlet

Conversation

@rithvik-doshi

@rithvik-doshi rithvik-doshi commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Change the response on server-side errors to return JSON instead of the default Tomcat HTML, plus other error html pages we have defined. This allows the frontend to parse the response cleanly and program behavior based on error codes and messages.

To test - induce any of the following kinds of errors and note the response has changed to valid json: 400, 401, 403, 404, 500, any Throwable from Monolith.

@rithvik-doshi
rithvik-doshi marked this pull request as ready for review March 31, 2026 13:51
@rithvik-doshi
rithvik-doshi requested a review from a team as a code owner March 31, 2026 13:51

@tevanburen tevanburen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionally: it returns json instead of html, which is better for FE to parse

@rithvik-doshi
rithvik-doshi marked this pull request as draft March 31, 2026 17:38
ryanweiler92 and others added 5 commits March 31, 2026 16:29
* feat: salesforce connector backend changes

* feat(function): made PR suggested changes

* fix: code cleanup

* feat: updated makeConnection() to getConnection()

* feat(function): made required changes

* fix: using proper utility methods and using proper redirect url based on request url

* fix: setting state as uuid and storing session attribute for connection id

---------

Co-authored-by: Kumari <skumari40@deloitte.com>
Co-authored-by: Maher Khalil <themaherkhalil@gmail.com>
Comment thread WebContent/WEB-INF/web.xml Outdated
<location>/error/json</location>
</error-page>
<error-page>
<error-code>401</error-code>

@agmontem-devel agmontem-devel Apr 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have an example where we generate a 401 tomcat default html page? I see examples for all the others

@agmontem-devel

agmontem-devel commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

The comment from Thomas makes me question the scenarios that motivated this change. There are still scenarios where errors yield html, but just not the default tomcat error page mappings we had. Is that ok? Was the desired change supposed to change other html error page responses?

For example:
Calling /Monolith/public_home/{uuid}/portals/blah will yield a 404 html response built in PublicHomeCheckFilter
Calling /Monolith/api/notthere gives a 0 content length 404

@tevanburen

Copy link
Copy Markdown
Contributor

The js sdk is ok with receiving html from the BE (as in, it won't cause problems), it just isn't able to parse it. For that reason, json is preferred. I think we should attempt to send json wherever we can - If Anthony found a few places where we can also update to json, that's great. But it's also not a problem if we aren't able to be thorough. I'll take as much json as can be given, and any html leftover will still be ok

@rithvik-doshi
rithvik-doshi marked this pull request as ready for review April 3, 2026 16:02
@rithvik-doshi
rithvik-doshi marked this pull request as draft April 3, 2026 16:02
themaherkhalil and others added 15 commits July 11, 2026 22:38
* feat: getting responses in codex

* feat: normalizing message content from codex

* feat: removing some logs

* feat: Handle Text & Tool Calling from Codex

* feat: removing some logs

* feat: exposing comms endpoint to handle streamable http (#243)

* fix: response type to be application json and sending json directly instead of sse format (#244)

* fix: set sse content type (#245)

* feat: troubleshooting test endpoint

* feat: cleaning up classes

* feat: filter tool args

* fix: clearing the insight map on mcp endpoints (#249)

* feat: updating anthropic message helper

* feat: WIP

* feat: fix handle non-streaming with images WIP

* feat: appending full prompt

* feat: updating anthropic messages endpoint to accept full history

* chore: update base image for local docker testing (#254)

* feat: support single string inputs on the responses api

* feat: WIP

* feat: anthropic endpoint with roomid

* feat: exposing filter to use local temporal access/secret key that is only available for localhost call on the same container

* feat: exposing utilty methods for grabbing details on the request

* feat: adding CodeAssistantFilter

* feat: message parts to communicate with models (#246)

* feat: using message parts

* chore: resolving compile error

* fix: import for hashmap missing

---------

Co-authored-by: Kunal Patel <kunal0137@gmail.com>
Co-authored-by: Maher Khalil <themaherkhalil@gmail.com>

* feat: WIP

* feat: adding hostname, port, and protocol to thread local

* feat: ignore csrf for specific endpoints (#262)

* feat: ignore csrf for some endpoints

* feat: exposing ignore path for csrf on openai, anthropic, and mcp endpoints

* chore: removing new lines at end of file

* chore: removing temp insight as all insights are now stored in the store since certain operations require it (#263)

* feat: don't json encode tool args

* chore: adding annotations (#265)

* feat: endpoint to return count of groups (#266)

* feat(user): usermetakyes returned in config call (#264)

* feat: new endpoint to get details about a specific group (#267)

* feat: endpoint takes in search term for count of users (#268)

* feat: also returning the count of the groups for pagination (#269)

* fix: file upload pushes to cloud, automated code formatting (#270)

* feat: exposing ollama endpoints (#272)

* fix: avoid some html escapes

* feat: smss file update pushes to notification db (#208)

* feat(project): implementation for in-app notification for smss file update

* feat(project): implementation of email notification for smss file update

* chore: refactor DbLoader and move notification logic to new NotificationDbUtils class

* reafactor: update the method name

* chore: refactor and add update project resource to accept notification and email

* chore: update all existing call sites to include the newly added userType field

* chore: cleanup to reflect changes in semoss

---------

Co-authored-by: Mahure <shmahure@deloitte.com>
Co-authored-by: Shubham Mahure <shubham.mahure@kanini.com>
Co-authored-by: Maher Khalil <themaherkhalil@gmail.com>

* fix: returning correct local port (#274)

* feat(config): add notification and audit log enabled flags for FE (#276)

* Update Tomcat version from 9.0.112 to 9.0.115

* feat: separate out system engines from user engines (#277)

* chore: switching from DIHelper.getInstance() to methods in Utility (#282)

* fix: check if the insight is not in the insight store to reinit for mcp, store insight based on session id if no auth key (#283)

* feat: adding executor service to close the open connection if unused after 30min for streaming mcp, adding executor service to manage thread pool for connections on sse (#284)

* fixing anthropic message ordering

* fix: race condition on resetIdleTimer (#286)

* fix: proper check for microsoft due to legacy method checking 'ms' instead of 'microsoft' (#287)

* fix: properly setting samesite on cookie and deleting cookie from client (#288)

* feat: token refresh with updates in semoss (#289)

* chore: update image tag (#290)

* hijack claude code subagent calls

* insight management

* handle subagent id

* fix: properly grabbing security db for admin setup (#292)

* fix: properly grabbing security db for admin setup

* chore: changing to try with resource

* fix: proper redirect for set initial admin (#294)

* WIP

* CC SSE Handling

* feat: salesforce connector (#173)

* feat: salesforce connector backend changes

* feat(function): made PR suggested changes

* fix: code cleanup

* feat: updated makeConnection() to getConnection()

* feat(function): made required changes

* fix: using proper utility methods and using proper redirect url based on request url

* fix: setting state as uuid and storing session attribute for connection id

---------

Co-authored-by: Kumari <skumari40@deloitte.com>
Co-authored-by: Maher Khalil <themaherkhalil@gmail.com>

* fix: making sure callback url includes the reverse proxy route (#298)

* chore: styled error page on 404 (#299)

* chore: moving util method, some code formatting (#300)

* feat: better SSE handling on Anthropic Endpoints

* fix: moving from lang to lang3 (#302)

* chore: update lz4 jar version

* only pull parent room id from headers

* chore: exclude assertj

* fix: pin jackson 3.x version

* WIP

* chore: removing unused APIFilter (#306)

* chore: remove unused servlet (#307)

* chore: removing unused api application (#308)

* fix: resolving sychronization error and adding javadoc to link saml code flow together (#309)

* fix: forgot to delete filter with PR#309 (#310)

* continue conversations

* feat: handle room id on parsed code assistant filter

* WIP

* fix: null check to avoid npe when checking for room in possibly non-existent header

* moving cc history streamer to monolith

* fix: search term using input sanitizer to allow for @, removing Constants.STACKTRACE from logger (#313)

* fix: search term using input sanitizer to allow for @ like email, removing Constants.STACKTRACE from logger

* chore: adding header

* feat: use code build

* moving find jsonl logic to semoss

* fix: remove auto comment codium

* new-file-watch-loop-for-cc

* moving semoss workflow dispatch to the-actions-org

* removing propogate-failure from semoss workflow dispatch

* fixing-build-constraints

* chore: Update Tomcat version to 9.0.117

* fix: removing agent user py process and symlink (#320)

* fix: track upload of file to engine in local git (#318)

* commit to app .git on upload of files and folders

* feat: extend git tracking to all engine types

- Git tracking in uploadEngineAssets() now applies to all engine types
  (function, database, model, vector, storage, guardrail), not just IProject
- Uses engine.getCatalogType() for version folder resolution

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Patel, Parth <parthpatel3+deloitte@deloitte.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Maher Khalil <themaherkhalil@gmail.com>

* feat: login for servicenow (#297)

* feat: servicenow connector backend changes

* feat(function): made minor changes

---------

Co-authored-by: Sneha Kumari <skumari40@deloitte.com>
Co-authored-by: Srk15 <41322670+Srk15@users.noreply.github.com>
Co-authored-by: Maher Khalil <themaherkhalil@gmail.com>

* feat: login for jira (#296)

* feat: Added endpoints for login and userinfo for jira

* fix: Removed unused constant and added required imports

* fix: Used Map datatype for connnection details and added required imports

---------

Co-authored-by: Subhadeepghosh1 <subhadghosh+deloitte@deloitte.com>
Co-authored-by: Maher Khalil <themaherkhalil@gmail.com>

* refactor: improve method organization, javadocs, and logging (#321)

* refactor: improve method organization, javadocs, and logging

* fix: keeping dynamic login consistent with /login2 url path

* fix: hard code the response type as function - dont use source type

* feat: changes to message emulation for streaming images from openai image model

* refactor: removing unused user workspace app, removing insight classes (#323)

* fix: changing class name with modification in semoss source code (#324)

* refactor: switching to run async pixel in a virtual thread (#325)

* fix: adding endpoints to match potential endpoints from clients, minor log updates (#326)

* fix: watcher startup as daemon (#328)

* handle thought signatures through cc harness

* flushing usage tokens

* cleanup

* capture openai token usage on openai endpoints

* fix: thinking blocks need to be dropped from return

* fix: serialization through gson

* fix: revert changes to anthropic helpers

* fix: revert chat completions helper

* fix: wip responses endpoint work

* fix: images endpoint wip

* fix: wip image endpoints

* fix: gson

* fix: making user password reset params more clear, cleanup of log messages on startup in servlet listener (#334)

* feat: engine resource REST endpoints + shared pixel runner helper (#335)

Add per-engine-type REST endpoints (database, model, storage, vector,
function) that wrap the corresponding pixel reactor calls. Each endpoint
accepts JSON or form-urlencoded payloads and dispatches through a new
ResourceUtility.runPixel helper.

New endpoints
- POST /api/database-{id}/{reload,query}, GET /api/database-{id}/{type,profile}
  (type returns IDatabaseEngine.DATABASE_TYPE + ENGINESUBTYPE)
- POST /api/model-{id}/{llm,embeddings,vision}
- POST /api/model-{id}/llmStreaming - SSE stream of raw chunks pulled from
  PixelJobManager.jobStreamMap, no OpenAI-format translation
- POST /api/storage-{id}/{list,listDetails,delete}
- POST /api/vector-{id}/{query,listDocuments,removeDocument}
- POST /api/function-{id}/execute, GET /api/function-{id}/definition
- GET /api/e-{id}/type - returns IEngine.CATALOG_TYPE for any engine

ResourceUtility.runPixel
- Returns HTTP 400 when the PixelRunner result carries
  PixelOperationType.ERROR or INVALID_SYNTAX, instead of the standard
  always-200 SEMOSS pixel envelope.
- Drops the per-request Insight (and clears the PixelJobManager job)
  via the new 3-arg PixelStreamUtility.collectPixelData(...,afterWrite)
  hook, so cleanup runs only after the response body finishes streaming.
- New parseRequestBody helper accepts both content types in one call.

EngineRouteResource
- Add public-static GSON, appendIfPresent, and error helpers shared
  across the engine-resource classes.
- Replace Constants.STACKTRACE log calls with descriptive {} messages
  that name the failed operation and engine id.
- Add Javadoc for updateSmssFile, imageDownload, and the auth helper.

WebUtility
- Move getClientIp here from ResourceUtility; update CACFilter,
  PIVFilter, SSOFilter, TrustedTokenFilter, TrustedTokenService, and
  UserResource accordingly.
- Replace remaining Constants.STACKTRACE calls with descriptive
  parameterized log messages.
- Fill in Javadoc on previously empty/skeleton blocks.

* feat: nameserver cleanup, runPython endpoint shortcut, dynamic endpoint method (#336)

* feat: reuse same room from claude code

* feat: reuse thread id from codex is passed in

* clean up

* feat: endpoints to get list and count of api_user's (#339)

* fixing-codex-headers-check

* feat: catch client disconnects on openai endpoints

* abstract isClientDisconnect to WebUtility class and apply other endpoints

* feat: upload into the user assets folder (#342)

* Update Tomcat version from 9.0.117 to 9.0.118

* feat: creating chroot template on application startup (#344)

* fix: ensure user context is set on access key actions

* fix: setting a new sessionid on successful first login (#346)

* fix: attempting to generate user on all endpoints (/config) for clients like python sdk (#347)

* removing encoding from anthropic endpoint

* remove encoding from LLM pixel in anthropic endpoints

* feat: a2a 1.0 release

* fix: update to reflect DefaultImageGeneratorUtil, remove non-ascii chars, log updates (#350)

* fix: room hash to contain Room object, close executor (#351)

* feat: initial commits for a2a forcing v1 with spec jar

* feat: removing <encode> on openai endpoints

* chore: update log statements and remove constants.stacketrace (#352)

* feat: adding utility class to build and run the pixel LLM command, switching all provider endpoints to call LLM reactor instead of direct engine method (#354)

* fix: proper ollama return in generate and chat endpoints, using utility methods in model pixel executor (#356)

* feat: adding groups for ms type

* Upgrading netty library version to 4.1.133 to remediate CVE-2026-42584

* fix: set the metadata on the original token before readonly init

* feat: new endpoints for github app creation and hookup with semoss project/app for webhook updates (#360)

* chore: update web.xml for new github endpoints (#361)

* fix: force netty jar to specific version

* handle thinking blocks correctly during stream

* feat: adding parameter if github app is private or public (#363)

* feat: using the user auth to enforce proper repo access before adding access, allowing multiple projects to reference the same repo (#364)

* feat: add user name to store in audit log table (#338)

* feat: USERNAME column addition in AuditLog table

* feat: hierarchy addition for userName

* chore: using utility method to grab username

---------

Co-authored-by: Maher Khalil <themaherkhalil@gmail.com>

* feat: add subdir as part of github service (#365)

* feat: add subdir as part of github service

* chore: code formatting

---------

Co-authored-by: Patel, Parth <parthpatel3+deloitte@deloitte.com>
Co-authored-by: Maher Khalil <themaherkhalil@gmail.com>

* playwright socket initial working version

* playwright socket initial working version

* chore: update tomcat and jars (#366)

* feat: adding parameter for admin check vs user check (#368)

* feat: consolidating the endpoints to utilize the strategy pattern within the token filler classes for the oauth flow (#369)

* feat: using token filler to handle addition of groups (#370)

* chore: removing unused resources (#371)

* fix: removing second loop thread to reuse existing thread started on create session

* fix: removing second loop thread to reuse existing thread started on create session

* fix: removing slf4j from a2a (#372)

* rename the classes for the websockets playwright

* rename the classes for the websockets playwright

* add initial playback functionality

* add initial playback functionality

* add endpoint for returning full recording envelope for a session

* add endpoint for returning full recording envelope for a session

* fix: closing playwright sessions on session ending

---------

Co-authored-by: Ryan Weiler <ryanweiler92@gmail.com>
Co-authored-by: kunal0137 <kunal0137@gmail.com>
Co-authored-by: Maher Khalil <themaherkhalil@gmail.com>
Co-authored-by: Shubham Mahure <shubham.mahure@kanini.com>
Co-authored-by: Anthony.Montemayor <Anthony.Montemayor@fda.gov>
Co-authored-by: samarthKharote <samarth.kharote@kanini.com>
Co-authored-by: Mahure <shmahure@deloitte.com>
Co-authored-by: agmontem-devel <117096159+agmontem-devel@users.noreply.github.com>
Co-authored-by: Sneha Kumari <115411589+snehakumari369@users.noreply.github.com>
Co-authored-by: Kumari <skumari40@deloitte.com>
Co-authored-by: Parth <parthpatel3@deloitte.com>
Co-authored-by: Patel, Parth <parthpatel3+deloitte@deloitte.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Srk15 <41322670+Srk15@users.noreply.github.com>
Co-authored-by: Subhadeep Ghosh <116416780+Subhadeepghosh1@users.noreply.github.com>
Co-authored-by: Subhadeepghosh1 <subhadghosh+deloitte@deloitte.com>
Co-authored-by: Rithvik Doshi <doshirithvik@gmail.com>
Co-authored-by: rithvik-doshi <81876806+rithvik-doshi@users.noreply.github.com>
Co-authored-by: radkalyan <107957324+radkalyan@users.noreply.github.com>
Co-authored-by: Mayer <tymayer@deloitte.com>
Co-authored-by: Ibrahim El Nemr <70034333+ibrahimelnemr@users.noreply.github.com>
chore: update a2a with db polling
… endpoints to use gson, gson to maintain long datatype instead of converting to decimal (#381)
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.