fix(core): redact report text after stripping terminal controls

DE
12h ago
+32-6

What

Reported error text is redacted after terminal controls are stripped, not before. A secret the app shows with an escape through its middle no longer reaches report.json, the markdown, JUnit, or the trace as text, and the same holds for a runtime skip reason and an expected-failure reason.

Why

serializeError ran the redactor first and stripVTControlCharacters second, so a value split by an escape was never matched whole and the strip then joined the halves back together. The report carried the complete value, against SECURITY.md (a secret never reaches a report as text) and against the ordering rule in AGENTS.md ("Redact before any cut: half a value is no longer a match"). report/ctrf.ts already redacts again after sanitising for this reason.

How it works

  1. serializeError redacts, strips, and redacts again for the message (packages/core/src/internal/errors.ts:446), the stack (:457), and every detail value (:513). The strip in the middle is what can put a split value back together, so the second redaction catches it; the first still catches a value the strip itself would mangle.
  2. A runtime skip reason goes through the same expression in both places it is recorded, on its own and beside a failure (packages/e2e/src/run/execute.ts:1017, :1024).
  3. An expected-failure reason does too (packages/e2e/src/run/expected-failure.ts:67).
  4. The order now matches packages/e2e/src/report/ctrf.ts:376.
  5. Coverage: a split value in an error message and in its details (packages/e2e/tests/unit/errors.test.ts), an expected-failure reason (packages/e2e/tests/unit/expected-failure.test.ts), and a runtime skip reason asserted through the report, the markdown, and JUnit on disk (packages/e2e/tests/integration/skip-after-failure.test.ts).

Issue

Fixes #2463

Verified

Ran it locally: yes

  • Built both packages, then ran the three suites:
pnpm --filter @e2e-dev/core run build && pnpm --filter e2e run build
pnpm --filter e2e exec vitest run tests/unit/errors.test.ts tests/unit/expected-failure.test.ts tests/integration/skip-after-failure.test.ts

tests/unit/errors.test.ts                  27 tests, 26 passed
tests/unit/expected-failure.test.ts        14 passed
tests/integration/skip-after-failure.ts     8 passed
  • The single failure, errors.test.ts > names the test line a failure unwound through when given the project root, fails identically on unmodified main in this Windows checkout (verified with the change stashed). It is a stack-path difference on Windows, unrelated to this diff.
  • pnpm --filter @e2e-dev/core run typecheck and pnpm --filter e2e run typecheck exit 0.

The bug and the fix, same probe on both checkouts, with a redactor that knows the whole value and a message holding that value split by one escape:

mainthis PR
message: the page showed SECRET-value-9381message: the page showed <secret:api-key>
details.observed: SECRET-value-9381details.observed: <secret:api-key>

Checklist

  • Changeset added (.changeset/redact-after-strip.md, a patch for @e2e-dev/core and e2e).
  • Breaking change: no.
  • Docs updated in the same PR: none needed, the code now does what SECURITY.md and docs/reference/security.mdx already state about secret redaction.
  • Contract change: no emitted type, config key, CLI flag, or wire format moves.
  • Engine contract change (e2e/engine): no.

Summary by CodeRabbit

  • Bug Fixes
    • Sensitive text in error messages, stack traces, details, runtime skip reasons, and expected-failure reasons is now consistently redacted—even when terminal formatting separates parts of the text.
    • Redaction is reflected in reports, Markdown, JUnit, and trace outputs, helping prevent sensitive text from appearing in generated results.