mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-11-18 01:54:23 +01:00
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:
15 files changed
+312
-21
No files matched your search
@@ -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> = {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user