Skip to content

feat(screenshot): skip screenshot when preview URL returns non-2xx #287

Description

@isadeks

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:

  1. Enable the Network CDP domain (Network.enable per session)
  2. Listen for Network.responseReceived events and capture the main-document response (type === 'Document', frame matches the navigation target)
  3. 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`)`
  4. 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

  • Main-document status captured via Network.responseReceived
  • Non-2xx aborts capture with a clear error message
  • Unit test in cdk/test/handlers/shared/agentcore-browser.test.ts covering 200 → screenshot, 404 → throw, 503 → throw
  • Smoke test in dev: deliberately point a deployment_status event at a 404 URL, confirm processor logs "Preview URL returned HTTP 404" and posts no PR comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2lowest priorityadaptersThird-party integrations: Linear, Slack, GitHub App, notification/deploy providersenhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions