mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-12-02 17:13:33 +01:00
fix: report a jsDelivr 404 as repo_not_found, not token_expired
Without owner access, a jsDelivr 404 was sent to the GitHub API probe, which cannot run for the CDN token and failed with token_expired. The path comes from the stored tree of a pinned commit, so a CDN 404 means the repository is no longer public. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
28b154b0eb
commit
f02999e774
2 files changed
+11
No files matched your search
@@ -3,6 +3,7 @@ import AnonymousError from "../AnonymousError";
|
||||
import { ExpiringMap } from "../expiring-map";
|
||||
import { octokit, waitForTokenGate, RateLimitDelayError } from "../GitHubUtils";
|
||||
import { GitHubBaseData } from "./GitHubBase";
|
||||
import { githubTokenContext } from "../github-token-context";
|
||||
|
||||
type Miss = "file_not_found" | "repo_not_found" | "commit_not_found";
|
||||
const results = new ExpiringMap<Miss>(2048);
|
||||
@@ -27,6 +28,10 @@ export async function classifyContentMiss(data: GitHubBaseData, token: string):
|
||||
if (active) return active;
|
||||
if (pending.size >= 64) throw new AnonymousError("cache_busy", { httpStatus: 503 });
|
||||
const probe = (async (): Promise<Miss> => {
|
||||
// A CDN read is commit-pinned and the path comes from that commit's stored
|
||||
// tree, so a CDN 404 means the repository is no longer public. The GitHub
|
||||
// API cannot be asked without the owner's access.
|
||||
if (githubTokenContext(token)?.cdnOnly) return "repo_not_found";
|
||||
const oct = octokit(token);
|
||||
const options = { owner: data.organization, repo: data.repoName, request: { timeout: 15_000 } };
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user