Repository navigation
Conversation
… image URLs GitHub App installation tokens get the same 404 as fine-grained PATs when downloading attachments from private repositories (josegonzalez#477), but the workaround was only used with -f. Older github.com/{owner}/{repo}/assets/* image URLs also 404 with both token types and render to the same JWT-signed URLs. Move the check into needs_jwt_workaround() so it can be tested directly, and pass the current token from get_auth() so App tokens are refreshed. The README now also notes that the workaround needs read access to contents: without it, POST /markdown returns 200 but leaves the image URLs unsigned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JefeUY9THfz2WzRtBGEP3U
Contributor
|
Looks good to merge. This fixes the same image download problem we had with fine-grained tokens, but for App tokens and the older image URLs. Thanks for the contribution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows up on #477 / #478.
GitHub App installation tokens hit the same limitation as fine-grained PATs: downloading
github.com/user-attachments/assets/*from a private repository returns 404. The Markdown API workaround from #478 works for them too, but it is only used when-fis given, so with--as-app/--app-idevery image in a private repository is skipped.The older repo-scoped image URLs (
github.com/{owner}/{repo}/assets/{user_id}/{uuid}) have the same problem (the original report in #477 lists them as well) and are never routed through the workaround either. The Markdown API renders them to the sameprivate-user-images.githubusercontent.comJWT-signed URLs.Changes
needs_jwt_workaround(args, repository, url). It is true for fine-grained or App tokens, on private repositories, foruser-attachments/assets/*or repo-scoped/assets/URLs./files/URLs still go the normal path, since the Markdown API does not sign them.get_auth(args, encode=False)to the Markdown API instead ofargs.token_fine. That is the raw token for both token types, and with--app-idit is the current (refreshed) installation token.needs_jwttest re-implemented the condition inline, so it would not have caught this. It is replaced by a parametrized test of the real function, plus a test thatdownload_attachmentssends the installation token to the Markdown API and downloads the JWT URL without it.Testing
pytest: 221 passed.flake8 --ignore=E501,E203,W503andrst-lint README.rstare clean.Same installation token (contents, issues and metadata read), same two private repositories,
--issues --issue-comments --attachments --as-app -t <ghs_...>:user-attachments/assets/*(7)jwt_workaround: true{owner}/{repo}/assets/*(5)jwt_workaround: trueEvery file has the same size as a direct download with an OAuth user token.
With a token that only has issues and metadata read,
POST /markdownreturns 200 but the image URLs in the HTML are not signed, so the workaround fails. The README now says the token needs read access to contents (already in the recommended permissions).In a full backup of two organizations with
--app-id, 71 of the 77 failed attachments were images in one of these two formats. The other 6 are/files/(PDF, audio, markdown), which stay unavailable as documented.Notes
manifest.jsonand not retried, so existing backups only pick up the fixed images after the manifest entries are removed (or from a fresh backup directory). I left that alone rather than adding retry logic for one class of 404.extract_attachment_urls()only matchesgithub.com/githubusercontent.comURLs, so attachments hosted on a GHES instance are never picked up, with or without this change. The only URLs that reach this code on GHES are github.com attachments pasted into GHES issues, which a GHES token cannot download directly either.🤖 Generated with Claude Code
https://claude.ai/code/session_01JefeUY9THfz2WzRtBGEP3U