Skip to content

feat(github): Load PR description images through the image proxy - #3370

Merged
BYK merged 4 commits into
mainfrom
feat/github-pr-images-proxy
Nov 13, 2026
Merged

BYK merged 4 commits into
mainfrom
feat/github-pr-images-proxy

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Problem

PR cards cannot show the images in a PR description. Most of them are github.com/user-attachments images, and they need GitHub auth on private repositories. The dashboard must not load a raw image URL.

Fix

  • The conversation detail API adds previewImages to each object annotation whose plugin serves images. Each src is an /api/images/:id?w=320 path with a signed id, with a ?w=640 2x srcSet. Hover cards, transcript cards and known objects show them as WebP.
  • The GitHub plugin adds an images source. On each read it checks that the viewer's linked GitHub login can see the repository (collaborator permission, cached for 10 minutes). A viewer without access, or without a linked login, gets 404.
  • Images are read through host egress as a system Actor, so egress policy, grants and audit apply. For an attachment, egress sends the App credential to github.com only. Junior then fetches the signed redirect target with no credential.
  • ImageFetch.location is new. Junior calls it only on a cache miss. ImageSourceContext now has egress.
  • The saved facts keep Junior artifacts and adds github.com/user-attachments/assets/<uuid>. Signed private-user-images URLs are never saved. The 4 KiB facts limit stays. No migration and no new OAuth scopes.

Not verified: that GitHub accepts an App installation token on github.com/user-attachments for private repositories. If it does not, the image route returns 404 and the card shows no image.

The Inbox row image is in #3035, which is not merged. It can use objectPreviewImages.

Screenshots

PR card (mock dashboard):

Before After
Dark before dark after dark
Light before light after light

Tests

  • images.test.ts: a repository member gets WebP at 640x400. An outsider and an unlinked viewer get 404, and nothing is fetched with the App credential for them. The signed URL gets no credential.
  • detail.test.ts: previewImages are signed /api/images/ paths for the GitHub source.
  • get-pull-request.test.ts: a UUID attachment is saved. Other attachment paths and signed URLs are dropped.
  • e2e conversation-object-links: the card image src and srcset are /api/images/ paths, and the image loads.

via @BYK.

--

View Session [Sentry]

Object cards now show the description images of a pull request through
/api/images with signed ids, never as raw URLs. The GitHub plugin adds an
images source that checks the viewer's repository access on each read.
Private attachments are read through host egress with the App credential,
and only the signed redirect target is fetched for the image.

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot requested a review from BYK November 13, 2026 15:34
@vercel

vercel Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 13, 2026 3:58pm UTC

Request Review

@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 13, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/junior-github/src/images.ts Resolved
…s reads

A viewer without access gets 404 from the image route, so the card hides
that image. A GitHub permission read that fails with a status other than
404, such as a rate limit, is not cached as a denial.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b955da3. Configure here.

Comment thread packages/junior-github/src/images.ts Resolved
A GitHub permission read that fails with a status other than 404 now logs
a warning and denies only that read, instead of an unhandled 500.
@BYK
BYK enabled auto-merge (squash) November 13, 2026 15:55
…-proxy

# Conflicts:
#	packages/junior-github/src/plugin.ts
#	packages/junior/tests/integration/api/conversations/detail.test.ts
@BYK
BYK merged commit 0bf2394 into main Nov 13, 2026
43 checks passed
@BYK
BYK deleted the feat/github-pr-images-proxy branch November 13, 2026 16:07
Comment on lines +87 to +101
async resolve(ctx, ref): Promise<ImageFetch | undefined> {
const image = decodeObjectImageRef(ref);
const key = image && OBJECT_KEY.exec(image.key);
if (!image || !key || !URL.canParse(image.url)) return undefined;
const kind = githubImageKind(new URL(image.url));
const login = linkedGitHubLogin(ctx.viewer);
if (!kind || !login) return undefined;
const repository = { name: key[2]!, owner: key[1]! };
if (!(await canSeeRepository(ctx, repository, login))) return undefined;
return kind === "artifact"
? { url: image.url }
: {
url: image.url,
location: () => githubAttachmentLocation(ctx.egress, image.url),
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attachment fetch authorized by object repo, not attachment access

After a collaborator check on the annotation repo key, Junior fetches any allowlisted user-attachments URL with the GitHub App credential. Embed a private attachment UUID in a PR on a still-accessible repo to read private images the viewer can no longer access on GitHub.

Evidence
  • resolve takes key and url from decodeObjectImageRef(ref) and only runs OBJECT_KEY + githubImageKind validation on them.
  • Authorization is solely canSeeRepository(ctx, repositoryFromKey, linkedGitHubLogin) against owner/repo from key.
  • On success, attachments call githubAttachmentLocation(ctx.egress, image.url), which uses system/App egress to github.com and returns the signed redirect target.
  • Nothing binds image.url to that repository, so a viewer with access to repo A can cause the App to load a private attachment that belongs to repo B.
Also found at 5 additional locations
  • packages/junior-github/src/plugin.ts:70-70
  • packages/junior-github/src/plugin.ts:179-179
  • packages/junior/src/chat/images/read.ts:56-60
  • packages/junior-github/src/tool-support/github-api.ts:91-105
  • packages/junior-plugin-api/src/object-facts.ts:36-37

Identified by Warden · security-review · XS4-RNG

BYK added a commit that referenced this pull request Nov 13, 2026
## Problem

Google link cards match only `docs.google.com`. A `drive.google.com`
link gets no card. Drive has no oEmbed provider, and Drive serves a
sign-in page to anonymous fetches, so the `web_page` card cannot preview
it either.

## Fix

- The Google `document` link type now also matches `drive.google.com`
`/file/d/<id>`, `/file/u/<n>/d/<id>`, `/open?id=<id>`,
`/drive/folders/<id>`, and `/drive/u/<n>/...`. These filters have a
host, so they win over the `web_page` catch-all.
- A Drive link to a Doc, Sheet, or Slides file gets the same card as its
`docs.google.com` link. It uses the shared `FILE_TYPES` map and file
card.
- Other files and folders use the existing `document` object type, with
a type label from the MIME type ("PDF", "Image", "Google Drive folder").
They show the name, owner, and modified time. I did not add a new object
type: the card has the same fields as a Doc card, and only the label
changes.
- File thumbnails go through the image proxy. The Google plugin adds an
`images` source that does the same viewer check as the card on each
read, through `ImageSourceContext.egress` (#3370), then fetches
`thumbnailLink` with Junior's Google token. It sends the token only to
`*.googleusercontent.com`. Facts hold only a signed `/api/images/...`
path, never `thumbnailLink`.
- Access uses the same viewer rule as Doc cards (`viewerCanOpen`). For
cards, the rule runs in `canView` (#3376), which shares one cached Drive
read with `resolve`. Thumbnails run it again on each image read, with no
cache (`readViewerFile`). Group-only shares, trashed files, and
shortcuts get no card and no thumbnail.
- Plugin API changes:
- `ObjectLinkContext.imagePath(ref, version?)` makes a signed image path
for a card.
- `readTool` is now a function of the resolved object, because a Drive
URL does not show its type before the lookup. Docs, Sheets, and Slides
from Drive name `readGoogleFile`. Other files name no tool.
  - The `document` and `web_page` facts share one `thumbnailUrl` schema.
- No new OAuth scopes and no migration. `drive.readonly` is already
granted.

| | Dark | Light |
| --- | --- | --- |
| Before: Drive links stay plain links |
![](https://junior-prod.sentry.dev/public/artifacts/24bf7c8e-9f8d-4988-8579-261069549e14.png)
|
![](https://junior-prod.sentry.dev/public/artifacts/0962ba3a-7438-45e0-8312-2d988f70d0d0.png)
|
| After: PDF chip and hover card |
![](https://junior-prod.sentry.dev/public/artifacts/9eafb33f-5331-419b-a5bd-1652c6379e1f.png)
|
![](https://junior-prod.sentry.dev/public/artifacts/4e380302-b891-4d98-9807-2c3fcecd0522.png)
|
| After: folder chip and hover card |
![](https://junior-prod.sentry.dev/public/artifacts/0665bf08-713f-4045-8cfe-e929ebfca3af.png)
|
![](https://junior-prod.sentry.dev/public/artifacts/6660ab37-cb02-4223-ba28-fdcf4819d9f5.png)
|

The before shots use the same mock thread with the Drive results removed
from `/api/objects`, which is what main returns for them.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3Ab4ab1661aa9222ed540303a34bce2d99 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Ab4ab1661aa9222ed540303a34bce2d99)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Ab4ab1661aa9222ed540303a34bce2d99/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 6c47b4f8 Deployed Nov 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant