fix(tests): add missing headers to diffs index.test.ts localReq mock#39047
fix(tests): add missing headers to diffs index.test.ts localReq mock#39047ademczuk wants to merge 1 commit intoopenclaw:mainfrom
Conversation
The `localReq()` helper in `index.test.ts` was missing a `headers` property, causing `hasProxyForwardingHints()` to throw when accessing `req.headers["x-forwarded-for"]` on an undefined object. This was introduced in 44881b0 which hardened proxied local viewer detection and updated `http.test.ts` but missed `index.test.ts`. Mirrors the fix pattern already applied in `http.test.ts:242`.
Greptile SummaryThis PR fixes a failing test in
The change is minimal, correct, and consistent with the existing codebase pattern. Confidence Score: 5/5
Last reviewed commit: 154c18c |
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
|
Consolidating into #39041 which has clean merge state and full green CI. Upgraded that PR's description to the full template. |
|
Duplicate triage result from top-100 open PR review. Keeping #39063 open as canonical for this fix. Why #39063 won:
Closing this PR to keep one active thread for the same fix and reduce reviewer/CI duplication. |
Summary
extensions/diffs/index.test.tsthrowsTypeError: Cannot read properties of undefined (reading 'x-forwarded-for')in theapplies plugin-config defaultstest case.checks (node, extensions)CI job due to this, even when the PR doesn't touch extensions code. Blocks merge readiness assessment for unrelated PRs.headers: {}to thelocalReq()mock helper sohasProxyForwardingHints()can safely accessreq.headers.index.test.ts. The identicallocalReq()helper inhttp.test.tsalready has this property (added in 44881b0).Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
hasProxyForwardingHints(), updatedhttp.test.tsbut missedindex.test.ts)User-visible / Behavior Changes
None. Test-only change.
Security Impact (required)
Repro + Verification
Environment
Steps
checks (node, extensions, pnpm test:extensions)CI jobextensions/diffs/index.test.tsExpected
All 258 extension test files pass (2260 tests).
Actual
1 test file fails, 257 pass. The specific failure:
Evidence
Before (from PR #38631 CI run 22803165182):
After (PR #39047 CI run 22803786316):
Human Verification (required)
localReq()helper inhttp.test.ts:235-244already includesheaders: input.headers ?? {}as the established pattern from the same commit (44881b0)index.test.ts'slocalReq()is the only other mock helper that was missedindex.test.tsfile:localReq()is called once (line 125), always with{ method, url }, never needs custom headersCompatibility / Migration
Failure Recovery (if this breaks)
Risks and Mitigations
None. Single-line addition to a test helper with no production code impact.