You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(backend): contain async route errors in the un-modularized routes
Express 4 does not forward async handler rejections, and the routes that open-legal-products#295
left outside modules/ were unguarded — a throw in any of them meant an
unhandled rejection and a socket held open until client timeout. Only the
workflows router defended itself. Its asyncRoute wrapper is now a shared
middleware (middleware/asyncRoute.ts) applied to audit, quickActions,
sourceDocuments, wordChat and workflowAddons, so a rejection reaches
app.ts's handleUnhandledError instead of nothing.
routerErrorHandler now only attributes the failure to a router in the log and
delegates the response to handleUnhandledError. Answering with a
router-specific 500 body would have contradicted the internal-error contract
main established: body-parser's 400/413 keep their own status and code,
everything else is the opaque {code:"internal_error"} body.
Also fixed in those route files, where errors were being silently converted to
success or not-found:
- quickActions: DELETE returned 204 with no row matched (now selects the
deleted ids and 404s when none); DB failures on the workflow lookup read as
404 (now 500, via the now-exported workflows.service.resolveWorkflowAccess
instead of a drifted private copy).
- workflowAddons: the import response hand-rebuilt the workflow shape and had
drifted from GET /workflows/:id on four fields — now uses the exported
withDatabaseWorkflow; a failed add-on lookup answered 404 (now 500).
- audit: lib/auditExport's private project-access helper duplicated
lib/access.listAccessibleProjectIds and had drifted from it (it re-counted
the caller's own shared projects and used a different `contains` encoding).
- sourceDocuments: a missing or rejected CourtListener token answered 502,
sending the user to check a service that was fine; credential failures now
answer 400 with a fixed message that never echoes the upstream body.
The history page's surface filter learns the "word" label, so the durable Word
chat audit rows open-legal-products#294 introduced (surface "word") are filterable rather than
showing a raw key.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0 commit comments