#23072: test(nodes-camera): guard optional response in invalid-url cases
cli
size: XS
## Summary
`pnpm tsgo` currently fails on `origin/main` due to a TypeScript union narrowing error in `src/cli/nodes-camera.test.ts`:
- `TS2339: Property 'response' does not exist on type ...`
This blocks the autonomous quality gate at the baseline step.
## Fix
- Narrow the case object before reading `response`:
- from: `if (testCase.response) { ... }`
- to: `if ("response" in testCase && testCase.response) { ... }`
This keeps behavior unchanged while satisfying TypeScript's discriminated-union safety.
## Validation
Ran full quality gate in a fresh `origin/main` worktree after the fix:
- `pnpm build` ✅
- `pnpm format:check` ✅ (advisory)
- `pnpm tsgo` ✅
- `pnpm lint` ✅
- `pnpm test` ✅
Log: `.openclaw-artifacts/quality-gates/gate-20260221-174132.log`
## AI-assisted disclosure
This change was prepared with assistance from the OpenClaw autonomous contributor loop.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixes TypeScript discriminated union narrowing error in `src/cli/nodes-camera.test.ts:175` by adding explicit property check before accessing optional `response` field. The test table includes cases where `response` is optional (e.g., the "non-https url" case doesn't need a mock response), so TypeScript requires narrowing the union type before property access.
The fix changes from `if (testCase.response)` to `if ("response" in testCase && testCase.response)` which properly narrows the type using a property existence check before the truthy check. This is the standard pattern for discriminated unions with optional properties and maintains identical runtime behavior while satisfying TypeScript's type safety requirements.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with no risk
- The change is a minimal, type-safe fix that addresses a TypeScript compiler error without altering runtime behavior. The author validated the fix through the full quality gate pipeline (build, format, tsgo, lint, test), and the change follows TypeScript best practices for discriminated union narrowing. The fix is localized to a single test file and uses the standard `"property" in object` pattern for type guards.
- No files require special attention
<sub>Last reviewed commit: 1f11978</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#22990: test: fix readonly typing regressions in CI check baseline
by bmendonca3 · 2026-02-21
72.0%
#21027: fix(tests): resolve TypeScript type errors in CLI test files
by kittipond2365 · 2026-02-19
71.8%
#17393: fix(ci): resolve TS2742 type error blocking all PRs
by miloudbelarebia · 2026-02-15
71.6%
#23139: test: fix flaky auth tests when OPENCLAW_GATEWAY_TOKEN is present
by Imccccc · 2026-02-22
71.6%
#23772: fix(ci): unblock repo-wide check gate type regressions
by SmithLabsLLC · 2026-02-22
71.6%
#23594: test(tui): fix mock typing in command handler tests
by Sashamine · 2026-02-22
71.4%
#20496: test(utils): add comprehensive unit tests for utility functions
by masifislamm · 2026-02-19
70.9%
#19885: test(gateway,browser): isolate tests from ambient OPENCLAW_GATEWAY_...
by NewdlDewdl · 2026-02-18
70.6%
#17237: fix(update): guard post-install imports after npm global update
by tdjackey · 2026-02-15
70.1%
#4243: fix: resolve Node.js punycode deprecation warning
by dylanneve1 · 2026-01-29
69.7%