Skip to content

fix(tests): add missing headers to diffs index.test.ts localReq mock#39063

Closed
Shennng wants to merge 1 commit intoopenclaw:mainfrom
Shennng:fix/diffs-test-headers
Closed

fix(tests): add missing headers to diffs index.test.ts localReq mock#39063
Shennng wants to merge 1 commit intoopenclaw:mainfrom
Shennng:fix/diffs-test-headers

Conversation

@Shennng
Copy link
Copy Markdown
Contributor

@Shennng Shennng commented Mar 7, 2026

Summary

  • Problem: extensions/diffs/index.test.ts throws TypeError: Cannot read properties of undefined (reading x-forwarded-for) in the applies plugin-config defaults test case.
  • Why it matters: Every open PR currently fails the checks (node, extensions) CI job due to this.
  • What changed: Added headers: input.headers ?? {} to the localReq() mock helper.

Changes

  • Modified extensions/diffs/index.test.ts to add headers property to localReq() function, matching the pattern already used in http.test.ts (commit 44881b0).

Testing

The fix resolves:

TypeError: Cannot read properties of undefined (reading x-forwarded-for)
 at hasProxyForwardingHints extensions/diffs/src/http.ts:180:9
 at resolveViewerAccess extensions/diffs/src/http.ts:193:58
 at extensions/diffs/index.test.ts:124:27

Compatibility

  • Backward compatible: Yes
  • No production code changed: Only test mock helper

Fixes #39047

Add headers property to localReq() mock helper in extensions/diffs/index.test.ts to match the pattern already used in http.test.ts (commit 44881b0). This fixes the test failure:

TypeError: Cannot read properties of undefined (reading 'x-forwarded-for')
  at hasProxyForwardingHints extensions/diffs/src/http.ts:180:9
  at resolveViewerAccess extensions/diffs/src/http.ts:193:58
  at extensions/diffs/index.test.ts:124:27

The hasProxyForwardingHints() function tries to access req.headers, but the mock in index.test.ts was missing this property while http.test.ts already had it.

Fixes openclaw#39047
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 7, 2026

Greptile Summary

This PR fixes a TypeError breaking the applies plugin-config defaults test in extensions/diffs/index.test.ts by adding the headers property to the localReq() mock helper. The production code's hasProxyForwardingHints() function expects req.headers to exist; the test mock was missing this property entirely.

Changes:

  • Added optional headers?: Record<string, string> parameter to localReq() with a default value of {} — identical to the existing pattern in extensions/diffs/src/http.test.ts.
  • No production code changes; test mock only.

Impact:

  • Unblocks CI for all open PRs that were failing the checks (node, extensions) job due to this TypeError.

Confidence Score: 5/5

  • This PR is safe to merge — it only modifies a test mock helper with no production code changes and fixes a CI-blocking TypeError.
  • The fix is minimal (6 insertions, 1 deletion), focused solely on test infrastructure, and correctly ensures the mock IncomingMessage matches Node.js contract by always providing a headers property. The implementation exactly mirrors the existing pattern in http.test.ts and directly resolves the root cause of the failing test.
  • No files require special attention.

Last reviewed commit: eeaa1d6

@steipete
Copy link
Copy Markdown
Contributor

steipete commented Mar 7, 2026

Please don't send PRs for CI stuff, it takes far longer to review a PR than to fix while we work.

@steipete steipete closed this Mar 7, 2026
steipete added a commit that referenced this pull request Mar 7, 2026
@steipete
Copy link
Copy Markdown
Contributor

steipete commented Mar 7, 2026

Superseded and landed directly on main (per maintainer direction to avoid merging CI-only PRs). Thank you @Shennng.

What I did:

SHA hashes:

  • original PR commit: eeaa1d6b161ea41870de030907b401e991924739
  • landed direct commit on main: 0f5317797

Thanks for surfacing and patching this quickly.

mrosmarin added a commit to mrosmarin/openclaw that referenced this pull request Mar 7, 2026
* main: (133 commits)
  reduce image size, offer slim image (openclaw#38479)
  fix(security): harden install base drift cleanup
  fix(agents): respect explicit provider baseUrl in merge mode (openclaw#39103)
  fix(agents): apply contextTokens cap for compaction threshold (openclaw#39099)
  fix(exec): block dangerous override-only env pivots
  fix(security): stage installs before publish
  fix(daemon): normalise whitespace in checkTokenDrift to prevent false-positive warning (openclaw#39108)
  fix(security): harden fs-safe copy writes
  refactor: dedupe bluebubbles webhook auth test setup
  refactor: dedupe discord native command test scaffolding
  refactor: dedupe anthropic probe target test setup
  refactor: dedupe minimax provider auth test setup
  refactor: dedupe runtime snapshot test fixtures
  fix: harden zip extraction writes
  fix(tests): stabilize diffs localReq headers (supersedes openclaw#39063)
  fix: harden workspace skill path containment
  fix(agents): land openclaw#38935 from @MumuTW
  fix(models): land openclaw#38947 from @davidemanuelDEV
  fix(gateway): land openclaw#39064 from @Narcooo
  fix(models-auth): land openclaw#38951 from @MumuTW
  ...
vincentkoc pushed a commit to BryanTegomoh/openclaw-fork that referenced this pull request Mar 8, 2026
openperf pushed a commit to openperf/moltbot that referenced this pull request Mar 8, 2026
mcaxtr pushed a commit to mcaxtr/openclaw that referenced this pull request Mar 8, 2026
Saitop pushed a commit to NomiciAI/openclaw that referenced this pull request Mar 8, 2026
GordonSH-oss pushed a commit to GordonSH-oss/openclaw that referenced this pull request Mar 9, 2026
jenawant pushed a commit to jenawant/openclaw that referenced this pull request Mar 10, 2026
dhoman pushed a commit to dhoman/chrono-claw that referenced this pull request Mar 11, 2026
senw-developers pushed a commit to senw-developers/va-openclaw that referenced this pull request Mar 17, 2026
V-Gutierrez pushed a commit to V-Gutierrez/openclaw-vendor that referenced this pull request Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants