mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-30 04:29:28 +02:00
fix bugs and report better errors
This commit is contained in:
@@ -84,8 +84,9 @@ export default async function (job: SandboxedJob<RepoJobData, void>) {
|
|||||||
} catch { /* ignored */ }
|
} catch { /* ignored */ }
|
||||||
}
|
}
|
||||||
logger.error("finished with error", {
|
logger.error("finished with error", {
|
||||||
|
...serializeError(error),
|
||||||
repoId: job.data.repoId,
|
repoId: job.data.repoId,
|
||||||
err: serializeError(error),
|
url: `/api/repo/${job.data.repoId}`,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await repo.updateStatus(
|
await repo.updateStatus(
|
||||||
@@ -94,8 +95,9 @@ export default async function (job: SandboxedJob<RepoJobData, void>) {
|
|||||||
);
|
);
|
||||||
} catch (persistError) {
|
} catch (persistError) {
|
||||||
logger.error("failed to persist ERROR status", {
|
logger.error("failed to persist ERROR status", {
|
||||||
|
...serializeError(persistError),
|
||||||
repoId: job.data.repoId,
|
repoId: job.data.repoId,
|
||||||
err: serializeError(persistError),
|
url: `/api/repo/${job.data.repoId}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@@ -304,6 +304,7 @@ router.get("/:repoId/", async (req: express.Request, res: express.Response) => {
|
|||||||
function validateNewRepo(repoUpdate: any): void {
|
function validateNewRepo(repoUpdate: any): void {
|
||||||
const validCharacters = /^[0-9a-zA-Z\-_]+$/;
|
const validCharacters = /^[0-9a-zA-Z\-_]+$/;
|
||||||
if (
|
if (
|
||||||
|
typeof repoUpdate.repoId !== "string" ||
|
||||||
!repoUpdate.repoId.match(validCharacters) ||
|
!repoUpdate.repoId.match(validCharacters) ||
|
||||||
repoUpdate.repoId.length < 3
|
repoUpdate.repoId.length < 3
|
||||||
) {
|
) {
|
||||||
@@ -312,6 +313,12 @@ function validateNewRepo(repoUpdate: any): void {
|
|||||||
httpStatus: 400,
|
httpStatus: 400,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (!repoUpdate.source) {
|
||||||
|
throw new AnonymousError("source_not_provided", {
|
||||||
|
object: repoUpdate,
|
||||||
|
httpStatus: 400,
|
||||||
|
});
|
||||||
|
}
|
||||||
if (!repoUpdate.source.branch) {
|
if (!repoUpdate.source.branch) {
|
||||||
throw new AnonymousError("branch_not_specified", {
|
throw new AnonymousError("branch_not_specified", {
|
||||||
object: repoUpdate,
|
object: repoUpdate,
|
||||||
|
|||||||
Reference in New Issue
Block a user