HarperFast / HarperFast/studio

[RUM] error.causes[] bypasses every redaction layer in beforeSend

Open
#1,665 0 comments 0 reactions 0 assignees View on GitHub
rum
Dominant language
TypeScript
Stars
5
Forks
4
Avg merge
1d 8h
Merged PRs (30d)
40

Description

The RUM SDK flattens an `Error`'s `cause` chain into `error.causes[{ message, type, stack }]` and sends it. [`beforeSend`](https://github.com/HarperFast/studio/blob/stage/src/integrations/datadog/beforeSend.ts) rewrites only `message`, `stack`, `handling_stack`, and `resource.url` — nothing walks `causes`.

So a cause's message or stack bypasses every layer we have: `redactErrorText`, `redactCredentialParams`, and the relayed-message type gate alike.

## Where a cause is attached today

`src/integrations/api/sse/streamOperation.ts` throws with one twice:

- `:75` — `new SSEUnsupportedError('Failed to open the SSE stream.', { cause: error })`
- `:121` — `new SSEInconclusiveError('The stream went idle before completing.', { cause: error })`

In both, the cause is the underlying fetch/transport error. Its text is not customer input, so this is a structural gap rather than a known leak — but it is the one path where redaction has no coverage at all, and any future `{ cause }` on an error that *does* carry server or user text would be published unredacted with nothing to catch it.

## Scale

Zero events carrying `error.causes` in the last 7 days of production RUM. Filed as defense-in-depth, not an active exposure.

## Suggested direction

Walk `causes[]` in `beforeSend` and apply the same treatment each entry's `message`/`stack` already gets at the top level — including the relayed-type check, so a cause of a relayed error is withheld too.

## Related

Found by the cross-model pre-push review of the PR that added the relayed-message type gate; scoped pre-existing and outside that diff.

Contributor guide

Open the contributing guide

Research direction

Read src/integrations/datadog/beforeSend.ts first, then inspect the cause attachment sites at lines 75 and 121 of src/integrations/api/sse/streamOperation.ts. Trace how top-level message and stack redaction is applied, and verify that error.causes entries receive the same treatment, including the relayed-error type gate.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
observability-sre, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.