Component
Adapters (GitHub) / Agent (browser tool)
Problem
captureScreenshot only checks Page.navigate's errorText field — but an HTTP 4xx/5xx response or an auth wall navigates "successfully" from CDP's perspective, and a 404 / login-page PNG gets posted as if it were the deployed app.
Spawned from krokoko's review on PR #241 (non-blocking nit). The screenshot guide acknowledges this gap; this issue tracks fixing it.
Expected behavior
When the preview URL returns a non-2xx status, the processor logs the status and skips posting the screenshot to GitHub / Linear.
Current behavior
A 404 or 503 page is captured and posted as if it were the deployed app. Reviewers see what looks like a broken deploy with no signal that the URL was unreachable.
Proposed solution
In cdk/src/handlers/shared/agentcore-browser.ts, before Page.captureScreenshot:
- Enable the
Network CDP domain (Network.enable per session)
- Listen for
Network.responseReceived events and capture the main-document response (type === 'Document', frame matches the navigation target)
- After
Page.loadEventFired, check the captured main-document status:
- 2xx → proceed to
Page.captureScreenshot as today
- non-2xx → throw
new Error(\Preview URL returned HTTP ${status}; skipping screenshot`)`
- The processor already treats screenshot-capture exceptions as "abort cleanly" (logs + skips PR comment), so the skip path needs no processor changes.
Auth-wall detection (out of scope)
Login pages are typically a 2xx HTML body, so HTTP status alone won't catch them. File a follow-up if needed.
Acceptance criteria
Component
Adapters (GitHub) / Agent (browser tool)
Problem
captureScreenshotonly checksPage.navigate'serrorTextfield — but an HTTP 4xx/5xx response or an auth wall navigates "successfully" from CDP's perspective, and a 404 / login-page PNG gets posted as if it were the deployed app.Spawned from krokoko's review on PR #241 (non-blocking nit). The screenshot guide acknowledges this gap; this issue tracks fixing it.
Expected behavior
When the preview URL returns a non-2xx status, the processor logs the status and skips posting the screenshot to GitHub / Linear.
Current behavior
A 404 or 503 page is captured and posted as if it were the deployed app. Reviewers see what looks like a broken deploy with no signal that the URL was unreachable.
Proposed solution
In
cdk/src/handlers/shared/agentcore-browser.ts, beforePage.captureScreenshot:NetworkCDP domain (Network.enableper session)Network.responseReceivedevents and capture the main-document response (type === 'Document', frame matches the navigation target)Page.loadEventFired, check the captured main-document status:Page.captureScreenshotas todaynew Error(\Preview URL returned HTTP ${status}; skipping screenshot`)`Auth-wall detection (out of scope)
Login pages are typically a 2xx HTML body, so HTTP status alone won't catch them. File a follow-up if needed.
Acceptance criteria
Network.responseReceivedcdk/test/handlers/shared/agentcore-browser.test.tscovering 200 → screenshot, 404 → throw, 503 → throw