Merge pull request #955 from tdurieux/fix/remaining-production-findings

fix: stop quota retry loops, narrow folder queries and diagnose upstream failures
This commit is contained in:
Thomas Durieux authored and GitHub committed 2026-11-14 18:22:19 +01:00
commit 88d0d0cd12
15 files changed
+312 -21

No files matched your search

+3 -1
View File
@@ -214,7 +214,9 @@ export default class Repository {
? new RegExp(`^${escapedPath}`)
: undefined;
if (opt.recursive === false) {
pathQuery = escapedPath ? new RegExp(`^${escapedPath}$`) : "";
// Equality bounds the path index to this directory. An anchored regex
// still scans its descendants before filtering out their paths.
pathQuery = opt.path || "";
}
const query: FilterQuery<IFile> = {
+5
View File
@@ -1,5 +1,10 @@
export function isQuotaFailure(code?: string): boolean {
return code === "quota_exceeded";
}
/** Persisted repository failures need the same client status as the original error. */
export function repositoryFailureStatus(code?: string): number {
if (isQuotaFailure(code)) return 402;
switch (code) {
case "repo_not_found": case "branch_not_found": case "commit_not_found": return 404;
case "repo_not_accessible": case "repository_not_accessible": return 403;
+5 -1
View File
@@ -139,10 +139,14 @@ export default class GitHubStream extends GitHubBase {
this.data.commit || "HEAD",
filePath
);
logger.debug("downloading via raw URL (LFS)", { url });
logger.debug("downloading via raw URL (LFS)");
const assertDownloadUrl = (value: URL) => {
if (value.protocol !== "https:" || value.username || value.password || value.port ||
!["raw.githubusercontent.com", "media.githubusercontent.com"].includes(value.hostname)) {
logger.warn("rejected upstream download destination", {
hostname: value.hostname, protocol: value.protocol,
reason: value.protocol !== "https:" ? "protocol" : value.username || value.password ? "credentials" : value.port ? "port" : "host",
});
throw new AnonymousError("upstream_error", { httpStatus: 502 });
}
};