Skip to content

Log unexpected API errors on the server without leaking data #37

Open

Description

@imshashank

When an HTTP business operation throws something unexpected, errorResponse in packages/core/http.ts returns { error: "INTERNAL_ERROR" } with status 500 and logs nothing. On a deployment that makes failures in /api/crm invisible.

src/app/api/integrations/cron/route.ts already logs in a safe structured form, for example console.error(JSON.stringify({ event, ... })), without SQL, message bodies or credentials.

Done when

  • Unexpected errors handled by errorResponse are logged once as a single JSON line with an event name, the error name and the operation if known.
  • The log never includes request bodies, SQL parameters, tokens or message content.
  • Expected domain errors (validation, conflicts, permission denials) are not logged as errors.
  • A test asserts the log call happens for an unexpected error and not for a validation error.

Activity

  1. added
    good first issue
    area: core
    on Oct 6, 2026
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

    area: coregood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions