Skip to content

HTTPError.message contains request-specific dynamic data, breaking error monitoring grouping (Sentry, Datadog, etc.) #658

@aruscus

Description

@aruscus

Description:

The gotBeforeErrorHook in GotHooks.ts appends the HTTP method, full URL, and the entire JSON-stringified response body into error.message: error.message += (${method} ${url}). ${JSON.stringify(detail)};

This means every error has a unique message containing request-specific values like correlation keys and process instance IDs.

Error monitoring tools (Sentry, Datadog, etc.) use error.message as a primary grouping key. Because every message contains unique identifiers, each occurrence creates a separate issue instead of grouping together, making it impossible to track error frequency or set alerts.

The structured data is already available on error.response.body (inherited from got.HTTPError), so embedding it into the message is redundant for programmatic access.

Suggested fix:

Use a static, parameterized message and expose the dynamic details as structured properties:

Instead of:
error.message += (${method} ${url}). ${JSON.stringify(detail)};

Use static message with structured properties
error.method = method;
error.url = url;
error.detail = detail;

error.message stays as the original got HTTPError message: "Response code 404 (Not Found)"

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions