block / block/buzz

CI: enforce check-pr-image-urls.sh on PR bodies — relay media URLs ship as broken images

Open
#6,726 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
32.7k
Forks
4.3k
Avg merge
1d 13h
Merged PRs (30d)
253

Description

## Problem

`scripts/check-pr-image-urls.sh` correctly rejects Buzz/relay `/media/.png` URLs in PR markdown, but **nothing enforces it**, so the guard only fires for someone who already knows to run it. The failure is silent and asymmetric: relay media requires auth, so the URLs render perfectly for the author (logged into Buzz) while GitHub's camo proxy fetches anonymously and gets `401 application/json` — every reviewer sees a broken image.

Confirmed on a live URL:

```
$ curl -s -o /dev/null -w '%{http_code} %{content_type}\n' \
https://buzz.block.builderlab.xyz/media/<64-hex>.png
401 application/json
```

Two PRs shipped this defect in the same week: #6720 (four broken images, since fixed) and #6536 (five, routed to its author). Both were reviewed and approved *in Buzz*, where the images resolve — so review does not catch it either.

## Why the current guard misses

- Not referenced anywhere in `.github/` — no CI job runs it.
- `scripts/post-screenshots.sh` runs it only when given the optional 3rd `body-file` arg (`post-screenshots.sh:74`). The common paths — `gh pr edit --body`, `gh pr create --body`, editing the body in the GitHub UI — are never checked.
- `AGENTS.md:283` and `desktop/src-tauri/src/managed_agents/screenshot_skill.md:19` both document it as a manual step.

`buzz upload file` is the natural reflex for anyone working inside a Buzz channel, which makes this an easy trap for both humans and agents.

## Proposed fix

A CI check on the PR body itself, which is the only place that catches all authoring paths (including the web UI):

- Workflow on `pull_request_target` with `types: [opened, edited]`, reading `github.event.pull_request.body` into a temp file and running `scripts/check-pr-image-urls.sh` on it. Should also scan PR comments on `issue_comment`, or at minimum the body.
- `pull_request_target` is needed to run the trusted base version of the script; it must not check out or execute PR-authored code.

A pre-push hook is **not** sufficient — the body is authored outside git and frequently edited after push.

Secondary hardening, cheap and worth doing regardless:

- Make the `body-file` arg to `post-screenshots.sh` the default path rather than optional.
- Have the checker also flag any `https?://` image whose host is not an allowlisted GitHub-safe host, rather than pattern-matching only relay/sprout URLs — an unknown third-party host has the same camo failure mode.

## Acceptance

- A PR whose body contains a relay `/media/.(png|jpg|webp|gif)` URL fails a required check, with the offending line and the `post-screenshots.sh` remedy in the failure output.
- Editing the body to fix it re-runs the check and passes.
- Verification is an anonymous fetch asserting `200 image/png` — not a logged-in eyeball.

Found while fixing #6720; filed as a follow-up rather than changing that PR.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.