Skip to content

[Bug]: Relative images in GitHub pull request descriptions show "Image unavailable" #27532

Open

Description

@imqdee

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

  1. On GitHub, open a pull request whose description links an image relative to the PR page, for example ![shot](../blob/<commit-sha>/shot.png?raw=true) where shot.png is committed at that commit.
  2. Check the description on github.com: the image renders.
  3. Open the same pull request in T3 Code's Pull Requests view.

Expected behavior

The image renders, as on github.com. GitHub leaves the destination as written (the body_html from the API keeps src="../blob/<sha>/shot.png?raw=true"), and the browser resolves it against the pull request URL, https://github.com/<owner>/<repo>/pull/<n>, giving https://github.com/<owner>/<repo>/blob/<sha>/shot.png?raw=true. That URL is one gitHubMediaUrl already claims, so on a private repository it should load through the authenticated github-media asset.

Actual behavior

Each image shows "Image unavailable". classifyMarkdownImageSource (packages/client-runtime/src/markdownImages.ts) reads any relative destination as a file in the local checkout, so T3 looks for <checkout>/../blob/<sha>/shot.png on disk. A root-relative destination such as /<owner>/<repo>/blob/<sha>/shot.png is read as a host file the same way. Relative text links in the description break for the same reason.

Pull request descriptions never refer to the reader's filesystem, so they should resolve against the pull request's own URL.

Impact

Minor bug or occasional failure

Version or commit

main @ 32ecd71

Environment

macOS, desktop and web clients, GitHub private repository

Workaround

Write absolute https://github.com/... URLs in the description.

Notes

#24706 adds a resolveRelativeUrl hook on the source control definition, applied to each image and link destination in the web and mobile PR views, and enables it for Forgejo (#18757). GitHub needs the same hook, resolving page-relative and root-relative destinations against the pull request URL.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions