Skip to content

fix(tests): allow console.error in malformed JSON security tests#36

Closed
bradfeld wants to merge 1 commit intodanshapiro:mainfrom
bradfeld:brad/fre-9-fix-9-pre-existing-test-failures-in-api-edge-casestestts
Closed

fix(tests): allow console.error in malformed JSON security tests#36
bradfeld wants to merge 1 commit intodanshapiro:mainfrom
bradfeld:brad/fre-9-fix-9-pre-existing-test-failures-in-api-edge-casestestts

Conversation

@bradfeld
Copy link
Copy Markdown
Contributor

Summary

  • Fix 9 pre-existing test failures in api-edge-cases.test.ts on main
  • Root cause: global console.error spy in test/setup/dom.ts throws on any unexpected error output, but Express's JSON parser legitimately logs parse errors to console.error
  • Uses the existing __ALLOW_CONSOLE_ERROR__ escape hatch in the 3 affected describe blocks (Malformed JSON, Payload Size, Content-Type Edge Cases)

Resolves FRE-9

Test plan

  • All 87 tests in api-edge-cases.test.ts pass (was 78/87)
  • Full suite: 2683 passed, 0 failed (was 2656 passed, 9 failed)
  • No other tests affected

Generated with Claude Code

The Malformed JSON, Payload Size, and Content-Type Edge Case tests
intentionally send invalid input to Express, which logs to console.error
via its built-in parser.  The global console.error spy in test/setup/dom.ts
treated these expected logs as failures.  Use the existing
__ALLOW_CONSOLE_ERROR__ escape hatch in the affected describe blocks.

Resolves FRE-9.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 87bdcb97b6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +319 to +320
beforeEach(() => {
;(globalThis as any).__ALLOW_CONSOLE_ERROR__ = true
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict console.error allowance to failing payload cases

Setting __ALLOW_CONSOLE_ERROR__ in a beforeEach for the entire "Payload Size Limits" suite disables the global unexpected-error guard for all tests in that block, not just the oversized-body case that legitimately triggers Express parser logging. As a result, tests like "accepts payload just under 1MB" can now emit unrelated console.error output without failing, which masks regressions that test/setup/dom.ts is designed to catch.

Useful? React with 👍 / 👎.

Comment on lines +1211 to +1212
beforeEach(() => {
;(globalThis as any).__ALLOW_CONSOLE_ERROR__ = true
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid muting console.error for all content-type tests

The beforeEach here turns off unexpected console.error assertions for the whole "Content-Type Edge Cases" suite, including cases that should parse or no-op cleanly. This broad allowance can let new server-side error logs slip through unnoticed in tests that currently expect normal behavior (e.g., text/plain and form-data requests), reducing the suite's ability to detect regressions.

Useful? React with 👍 / 👎.

@danshapiro
Copy link
Copy Markdown
Owner

Nice defensive fix! Even though the failures weren't reproducible on Linux, they may be platform-dependent (Mac/different Node versions).

What was good:

  • Used the project's existing __ALLOW_CONSOLE_ERROR__ escape hatch — no new patterns
  • Targeted and minimal — only the 3 describe blocks that intentionally trigger parse errors
  • Helpful comment on the first block explaining why

Notes:

  • Fresheyes and independent testing confirmed the fix is harmless (tests pass with and without it)
  • Express's logerror suppresses console.error when NODE_ENV=test, so the flags are likely no-ops on Linux — but they provide safety for environments where the behavior differs

All 2852 tests pass (186 files, 0 failures).

Merged to main. Thanks! 🎉

— Codex CLI

@danshapiro danshapiro closed this Feb 13, 2026
danshapiro pushed a commit that referenced this pull request Feb 15, 2026
Removed 5 items per Dan's review:
- #14 (FAB) — already exists
- #18 (pinch-to-zoom font) — keep default browser zoom
- #36 (shake to reconnect) — rejected
- #37 (swipeable sessions) — rejected
- #44 (low bandwidth mode) — rejected

Updated 2 items:
- #16/17 (key toolbar) — added draggable/scrollable bar with F1-F12
- #31/33 (scrollback) — changed to one-finger scroll, press-hold
  for text selection, no browser-level vertical scrollbar

Renumbered from 45 to 40 items. Updated priority tiers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants