Skip to content

test(e2e): assert invalid multipart error log - #1272

Merged
chimurai merged 1 commit into
masterfrom
e2e-invalid-multipart-error-log
Jun 23, 2026
Merged

chimurai merged 1 commit into
masterfrom
e2e-invalid-multipart-error-log

Conversation

@chimurai

@chimurai chimurai commented Jun 23, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Tests
    • Enhanced error logging verification for multipart injection rejection scenarios, confirming the proxy middleware reports the expected error message (including target and error documentation details).

@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: db558442-4d71-487d-b0b9-24c49538b354

📥 Commits

Reviewing files that changed from the base of the PR and between 84fbc36 and dbeaa2a.

📒 Files selected for processing (1)
  • test/e2e/http-proxy-middleware.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/e2e/http-proxy-middleware.spec.ts

📝 Walkthrough

Walkthrough

The multipart CRLF injection rejection test in test/e2e/http-proxy-middleware.spec.ts is extended with a loggerSpy implementing the Logger interface (mocked via vi.fn()), wired into the middleware via logger: loggerSpy, and new assertions verify that loggerSpy.error is called with the expected error message and URLs when HPM_ERR_INVALID_MULTIPART_FIELD_VALUE is triggered.

Changes

Logger error assertion in CRLF injection test

Layer / File(s) Summary
loggerSpy setup, wiring, and error assertion
test/e2e/http-proxy-middleware.spec.ts
Adds a loggerSpy object with vi.fn() mocks for info, warn, and error; passes it as logger to the proxy middleware configuration; and extends the injection rejection assertions to verify loggerSpy.error is called with the [HPM] Error occurred while proxying request %s to %s [%s] (%s) template, the target URL, and the Node.js error documentation URL.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • chimurai/http-proxy-middleware#1233: Both PRs add or verify proxy middleware error logging through a mocked logger.error in e2e tests, asserting the same "[HPM] Error occurred while proxying request…" formatted message via the shared logger-plugin error-log path.

Poem

🐇 A spy was placed inside the test,
To catch each error with interest.
CRLF tricks? The logger saw!
HPM_ERR broke no law—
Just logged the URL and the doc,
And the rabbit ticked the clock. ✅

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test(e2e): assert invalid multipart error log' accurately describes the main change—adding assertions to verify error logging in an end-to-end test for invalid multipart field value handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch e2e-invalid-multipart-error-log

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/e2e/http-proxy-middleware.spec.ts`:
- Around line 182-188: The test assertion in the CRLF rejection test is brittle
because it hardcodes values that vary at runtime. Replace the hardcoded request
host with expect.any(String) since the host is dynamic, and update the target
URL from 'http://localhost:8000/' to the correct actual value
'http://localhost:8004/' that matches the runtime configuration. This allows the
test to validate the semantic shape and structure of the logger call while being
resilient to dynamic values that are not relevant to the error condition being
tested.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d0a96649-0f51-4832-b082-57fabdc55047

📥 Commits

Reviewing files that changed from the base of the PR and between 22281bf and 84fbc36.

📒 Files selected for processing (1)
  • test/e2e/http-proxy-middleware.spec.ts

Comment thread test/e2e/http-proxy-middleware.spec.ts
@chimurai
chimurai force-pushed the e2e-invalid-multipart-error-log branch from 84fbc36 to dbeaa2a Compare June 23, 2026 20:06
@pkg-pr-new

pkg-pr-new Bot commented Jun 23, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/http-proxy-middleware@1272

commit: dbeaa2a

@chimurai
chimurai merged commit 006f1a4 into master Jun 23, 2026
24 checks passed
@chimurai
chimurai deleted the e2e-invalid-multipart-error-log branch June 23, 2026 20:08
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 95.183%. remained the same — e2e-invalid-multipart-error-log into master

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