fix: preserve probe errors and complete refresh alerts

This commit is contained in:
Thomas Durieux committed 2026-10-09 06:17:40 +00:00
1 parent 2b20abe0a5
commit 9a2707d4b8
6 files changed
+102 -11

No files matched your search

+4 -1
View File
@@ -270,7 +270,10 @@ export default class AnonymizedFile {
fetchFileInfoFromPath?: (filePath: string) => Promise<IFile | null>;
};
if (typeof source.fetchFileInfoFromPath !== "function") return null;
const recovered = await source.fetchFileInfoFromPath(this.anonymizedPath);
const recovered = await source.fetchFileInfoFromPath(this.anonymizedPath).catch(error => {
void notifyOwnerAccessProblem(this.repository.owner.id, error);
throw error;
});
if (!recovered) return null;
recovered.repoId = this.repository.repoId;
recovered.treeGeneration = this.repository.model.treeGeneration;
+8 -3
View File
@@ -628,6 +628,14 @@ export default class Repository {
/** Update the repository if a new commit exists. */
async updateIfNeeded(opt?: { force: boolean }): Promise<void> {
try { await this.refreshIfNeeded(opt); }
catch (error) {
void notifyOwnerAccessProblem(this.owner.id, error);
throw error;
}
}
private async refreshIfNeeded(opt?: { force: boolean }): Promise<void> {
this.assertNotArchived();
if (
this._model.options.expirationMode !== "never" &&
@@ -658,9 +666,6 @@ export default class Repository {
repo: this.source.data.repoName,
repositoryID: this.model.source.repositoryId,
force: true,
}).catch(error => {
void notifyOwnerAccessProblem(this.owner.id, error);
throw error;
});
// update the repository name if it has changed. Persist it
+6 -2
View File
@@ -52,7 +52,9 @@ export async function classifyGitHubMissError(
repo: data.repoName,
});
return "commit_not_found";
} catch {
} catch (probeError) {
if ((probeError as { status?: number; httpStatus?: number }).status !== 404 &&
(probeError as { httpStatus?: number }).httpStatus !== 404) throw probeError;
// Repo no longer exists at owner/repo. Try to recover via the cached
// numeric GitHub id — if the repo was renamed, GET /repositories/{id}
// resolves to its new full_name. See #409.
@@ -87,7 +89,9 @@ export async function classifyGitHubMissError(
return "repo_renamed";
}
return "repo_not_found";
} catch {
} catch (probeError) {
if ((probeError as { status?: number; httpStatus?: number }).status !== 404 &&
(probeError as { httpStatus?: number }).httpStatus !== 404) throw probeError;
return "repo_not_found";
}
}
+2 -1
View File
@@ -77,7 +77,8 @@ export class GitHubRepository {
try {
await oct.repos.get({ owner: this.owner, repo: this.repo });
repoExists = true;
} catch {
} catch (probeError) {
if ((probeError as { status?: number }).status !== 404) throw probeError;
repoExists = false;
}
throw new AnonymousError(
+7 -4
View File
@@ -412,10 +412,13 @@ export default class GitHubStream extends GitHubBase {
size: data.size,
};
} catch (error) {
logger.debug("fetchFileInfoFromPath miss", {
filePath,
error: serializeError(error),
});
if ((error as { status?: number }).status !== 404) throw error;
// A missing file and lost repository access both return 404. Only
// report a normal miss after the repository probe remains readable.
const code = await classifyGitHubMissError(error, this.data);
if (code === "repo_not_found") {
throw new AnonymousError(code, { httpStatus: 404, cause: error as Error });
}
return null;
}
}