Skip to content

fix(test): add missing headers to diffs index test mock#39041

Closed
ademczuk wants to merge 3 commits intoopenclaw:mainfrom
ademczuk:fix/diffs-test-mock-headers
Closed

fix(test): add missing headers to diffs index test mock#39041
ademczuk wants to merge 3 commits intoopenclaw:mainfrom
ademczuk:fix/diffs-test-mock-headers

Conversation

@ademczuk
Copy link
Copy Markdown
Contributor

@ademczuk ademczuk 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, even when the PR doesn't touch extensions code. Blocks merge readiness assessment for unrelated PRs.
  • What changed: Added headers: {} to the localReq() mock helper so hasProxyForwardingHints() can safely access req.headers.
  • What did NOT change: No production code touched. Only the test mock helper in index.test.ts. The identical localReq() helper in http.test.ts already has this property (added in 44881b0).

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Root cause: commit 44881b0 introduced hasProxyForwardingHints() and updated http.test.ts but missed index.test.ts
  • Unblocks: all open PRs currently failing the extensions CI job

User-visible / Behaviour Changes

None. Test-only change.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • CI runner (Ubuntu, node)
  • Reproducible on any branch based on main after 44881b0

Steps

  1. Open any PR targeting main
  2. Wait for checks (node, extensions, pnpm test:extensions) CI job
  3. Observe failure in extensions/diffs/index.test.ts

Expected

All 258 extension test files pass (2260 tests).

Actual

1 test file fails, 257 pass. The specific 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

Evidence

Before (from CI run on another open PR):

FAIL extensions/diffs/index.test.ts > diffs plugin registration > applies plugin-config defaults
TypeError: Cannot read properties of undefined (reading 'x-forwarded-for')
Test Files  1 failed | 257 passed (258)
Tests       1 failed | 2258 passed | 1 skipped (2260)

After (CI on this branch):

checks (node, extensions, pnpm test:extensions)  pass  1m44s

Human Verification (required)

  • Verified the localReq() helper in http.test.ts:235-244 already includes headers: input.headers ?? {} as the established pattern from the same commit (44881b0)
  • Confirmed index.test.ts's localReq() is the only other mock helper that was missed
  • Checked the full index.test.ts file: localReq() is called once (line 125), always with { method, url }, never needs custom headers
  • CI confirms fix: extensions job passes on this PR

Compatibility / Migration

  • Backwards compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Failure Recovery (if this breaks)

  • Revert this single commit
  • Zero risk: only adds an empty object to a test mock

Risks and Mitigations

None. Single-line addition to a test helper with no production code impact.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 7, 2026

Greptile Summary

This PR fixes a test crash in extensions/diffs/index.test.ts by adding headers: {} to the localReq() mock helper. The fix correctly addresses the root cause: hasProxyForwardingHints() accesses req.headers, but the mock in this file hadn't been updated when that function was introduced.

  • The fix is minimal and correct — headers: {} satisfies the property access without adding unnecessary complexity.
  • The approach is consistent with the existing localReq() in extensions/diffs/src/http.test.ts, which also initialises headers to {} by default.
  • No production code is touched; this is a pure test-only change.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, test-only fix with no production code changes.
  • The change adds a single property (headers: {}) to a test mock, directly fixing the reported TypeError. It is consistent with the equivalent helper in src/http.test.ts, introduces no new logic, and has no impact on production behaviour.
  • No files require special attention.

Last reviewed commit: 2b7d0bd

@openclaw-barnacle openclaw-barnacle bot added channel: discord Channel integration: discord channel: telegram Channel integration: telegram labels Mar 7, 2026
@ademczuk ademczuk force-pushed the fix/diffs-test-mock-headers branch from 3680ba7 to 3b0b91e Compare March 7, 2026 17:49
@ademczuk
Copy link
Copy Markdown
Contributor Author

ademczuk commented Mar 7, 2026

@steipete -- this could use a review when you've got a moment.

Context: 1-line test mock fix for the extensions/diffs CI failure introduced by 44881b0. XS PR, 1 file, all 29 CI checks green. Unblocks every open PR currently failing the extensions job.

The "Repro + Verification" section in the description has the full stack trace and before/after CI evidence.

@steipete
Copy link
Copy Markdown
Contributor

steipete commented Mar 7, 2026

Duplicate triage result from top-100 open PR review.

Keeping #39063 open as canonical for this fix.

Why #39063 won:

  • same intended bug fix in extensions/diffs
  • narrower scope (avoids extra unrelated test churn)
  • cleaner review path with one focused patch

Closing this PR to consolidate on a single implementation path.

@steipete steipete closed this Mar 7, 2026
@ademczuk ademczuk deleted the fix/diffs-test-mock-headers branch March 7, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: telegram Channel integration: telegram size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants