diff --git a/panel/src/i18n/resources/en-US/errors.json b/panel/src/i18n/resources/en-US/errors.json index 18b1aae..1daf4dc 100644 --- a/panel/src/i18n/resources/en-US/errors.json +++ b/panel/src/i18n/resources/en-US/errors.json @@ -67,6 +67,7 @@ "already_terminal": "This build already finished — there is nothing to cancel.", "build_unavailable": "Image builds aren't available right now.", "build_logs_unavailable": "Build logs aren't available right now.", + "scan_document_not_kept": "This build kept no copy of that scan file: it was too large to keep, or the step that writes it failed.", "already_reviewed": "This submission has already been reviewed.", "context_changed": "The submitter uploaded the build context again after you reviewed it. Download and review the new upload before approving.", "submission_quota_exceeded": "Your submission quota is full: too many pending reviews, or your pending and rejected uploads fill your storage allowance. Withdraw a pending one, or wait: a rejected upload frees its space 7 days after review, and approved ones don't count.", diff --git a/panel/src/i18n/resources/zh-CN/errors.json b/panel/src/i18n/resources/zh-CN/errors.json index 5bca344..71425d6 100644 --- a/panel/src/i18n/resources/zh-CN/errors.json +++ b/panel/src/i18n/resources/zh-CN/errors.json @@ -67,6 +67,7 @@ "already_terminal": "该构建已经结束,无法重复取消。", "build_unavailable": "构建功能当前不可用。", "build_logs_unavailable": "构建日志暂时不可用。", + "scan_document_not_kept": "这次构建没有留下这份扫描文件:文件太大没有保存,或者生成它的步骤失败了。", "already_reviewed": "该提交已经审核过了。", "context_changed": "提交者在你审阅之后重新上传了构建上下文。请重新下载并审阅新的上传再通过。", "submission_quota_exceeded": "你的提交配额已满:待审核提交过多,或待审核和被拒绝的上传占满了存储额度。可以撤回一个待审核的提交;被拒绝的上传在审核 7 天后释放空间,已批准的不占额度。", diff --git a/panel/src/lib/api.test.ts b/panel/src/lib/api.test.ts index f3b8745..f60cf2f 100644 --- a/panel/src/lib/api.test.ts +++ b/panel/src/lib/api.test.ts @@ -1066,6 +1066,24 @@ describe("responses that are not the API's JSON", () => { await expect(api.me()).rejects.toMatchObject({ status: 200, code: "upstream_unavailable" }); }); + it("names a scan file the build did not keep in the UI language, never in the backend's English", async () => { + const { default: i18next } = await import("i18next"); + const err = { + status: 404, + code: "scan_document_not_kept", + message: "this build's scan kept no sbom: it was too large to keep, or the step that writes it failed", + }; + expect(humanizeError(err)).toBe( + "This build kept no copy of that scan file: it was too large to keep, or the step that writes it failed.", + ); + await i18next.changeLanguage("zh-CN"); + try { + expect(humanizeError(err)).toBe("这次构建没有留下这份扫描文件:文件太大没有保存,或者生成它的步骤失败了。"); + } finally { + await i18next.changeLanguage("en-US"); + } + }); + it("maps an unknown 5xx code to the unavailable line", () => { expect(humanizeError({ status: 500, code: "internal", message: "internal error" })).toMatch(/unavailable/i); expect(humanizeError({ status: 413, code: "error", message: "Payload Too Large" })).toMatch(/larger/i); diff --git a/panel/src/lib/api.ts b/panel/src/lib/api.ts index 5dec024..c190917 100644 --- a/panel/src/lib/api.ts +++ b/panel/src/lib/api.ts @@ -1169,6 +1169,8 @@ export function humanizeError(e: unknown): string { return t("build_unavailable"); case "build_logs_unavailable": return t("build_logs_unavailable"); + case "scan_document_not_kept": + return t("scan_document_not_kept"); case "already_reviewed": return t("already_reviewed"); case "context_changed": diff --git a/panel/src/pages/admin/BuildScanPanel.test.tsx b/panel/src/pages/admin/BuildScanPanel.test.tsx index b1f219a..b52b2b9 100644 --- a/panel/src/pages/admin/BuildScanPanel.test.tsx +++ b/panel/src/pages/admin/BuildScanPanel.test.tsx @@ -124,7 +124,7 @@ describe("BuildScanPanel", () => { }); await userEvent.click(within(panel).getByRole("button", { name: "Trivy report" })); expect((await within(panel).findByRole("alert")).textContent).toBe( - "Couldn't download: this build's scan kept no report: it was too large to keep, or the step that writes it failed", + "Couldn't download: This build kept no copy of that scan file: it was too large to keep, or the step that writes it failed.", ); });