fix: stop quota retry loops and narrow directory queries

This commit is contained in:
Thomas Durieux committed 2026-11-14 13:03:22 +00:00
1 parent 511dcd7067
commit b456ab8739
15 files changed
+312 -21

No files matched your search

+3 -1
View File
@@ -213,7 +213,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 });
}
};