Skip to content

Add a global Express error-handling middleware (clean JSON instead of HTML 500) #116

Description

@bharatsachya

Type: architecture · Difficulty: medium

There is no global error-handler registered after registerRoutes (packages/server/src/index.ts:87). In Express 5 a rejected async handler hits the default handler → an HTML 500 with a stack trace, not the { error } JSON the API uses elsewhere. Most routes (reposRoute, statsRoute, githubIndexRoute, …) have no try/catch around DB/queue calls, so Mongo/Neo4j/Redis being down yields a raw stack.

Do: add one error-handling middleware after registerRoutes that maps known @bb/errors (e.g. MongoNotConnectedError, Neo4jConfigError, RedisConnectError) to 503 with { error, hint }, and unknown errors to 500 { error }. Models to copy: mcpStatsRoute.ts:28, deleteRoute.ts:17.

Done when: infra-down requests return clean JSON with a hint, never an HTML stack.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions