Comfy-Org / Comfy-Org/ComfyUI_frontend

reportError logs the raw cause to the console on every report

Open Beginner friendly
#17,287 0 comments 0 reactions 0 assignees View on GitHub
audit:security
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Problem / Goal

`reportError()` writes a console line for every report unless `logToConsole: false`, and it logs the raw `cause`:

```ts
// src/platform/telemetry/reportError.ts
if (options.logToConsole !== false) {
const log = options.level === 'warning' ? console.warn : console.error
log(`${REPORTED_ERROR_PREFIX}${options.errorType}`, cause)
}
```

Logging the `Error` object rather than its message/stack means every own-property an error subclass hangs off itself gets expanded in the console. `AgentApiError` stores the parsed API response body:

```ts
// src/workbench/extensions/agent/services/agent/agentRestClient.ts
export class AgentApiError extends Error {
readonly status: number
readonly body: unknown
}
```

so any `reportError` reached from an agent request path puts response data in the browser console. The console line is unconditional, not a no-sink fallback, so this applies in production — not only local dev and self-hosted.

## Proposed Solution

Log the stack instead of the object:

```ts
log(
`${REPORTED_ERROR_PREFIX}${options.errorType}`,
cause instanceof Error ? (cause.stack ?? `${cause.name}: ${cause.message}`) : cause
)
```

Name, message and frames — everything the line is actually read for — are preserved; the custom payload properties are not.

## Acceptance Criteria

- [ ] A `reportError` call whose cause carries an extra property does not put that property's value on the console
- [ ] The console line still shows error type, message and stack frames
- [ ] `REPORTED_ERROR_PREFIX` still matches, so `datadogRumBeforeSend` keeps dropping the untagged RUM copy
- [ ] Regression test in `src/platform/telemetry/reportError.test.ts`

---

Raised by CodeRabbit on #17001 (https://github.com/Comfy-Org/ComfyUI_frontend/pull/17001#discussion_r3962162535) against a narrower no-sink fallback that has since been dropped from that PR, because the landed implementation on main supersedes it. The finding survives against the landed version with wider exposure.

Contributor guide

Open the contributing guide

Research direction

Read `src/platform/telemetry/reportError.ts` and its regression tests in `src/platform/telemetry/reportError.test.ts`. Check how the console output and `REPORTED_ERROR_PREFIX` are used, then run the test file. Done means extra error properties are not exposed in the console, while the error type, message, stack frames, and prefix are preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
observability
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
85/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.