From 8a15d9feedc62dc9695246dceda9271a6d0a08e9 Mon Sep 17 00:00:00 2001 From: terencecho <3916587+terencecho@users.noreply.github.com> Date: Wed, 11 Nov 2026 04:49:44 +0000 Subject: [PATCH] fix(share): explain the hourly review-version limit (#7539) The review service can now refuse a new version with 429 export_hourly_limit (too many versions in the last hour). It had no sentence, so the person read "Couldn't add this version. Try again." and every retry was refused again. It now says the hourly limit was reached and when to try again, from the server's Retry-After, falling back to "in an hour" when none is sent. The daily limit keeps its "tomorrow" fallback. Co-authored-by: Claude Opus 5.5 --- packages/share/src/reviewVersionSentences.mjs | 10 ++++--- .../tests/reviewVersionSentences.test.mjs | 29 +++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 packages/share/tests/reviewVersionSentences.test.mjs diff --git a/packages/share/src/reviewVersionSentences.mjs b/packages/share/src/reviewVersionSentences.mjs index 20572da0c9..96c42fd65b 100644 --- a/packages/share/src/reviewVersionSentences.mjs +++ b/packages/share/src/reviewVersionSentences.mjs @@ -11,8 +11,10 @@ const SAID = { export_too_large: "This video is over 2 GB, the most a review page takes. Export a smaller one.", export_too_long: "This video is over 30 minutes, the most a review page takes. Export a shorter one.", + export_hourly_limit: (error) => + `You've added the most versions for this hour. Try again ${laterIn(error.retryAfterMs, "in an hour")}.`, export_daily_limit: (error) => - `You've added the most versions for today. Try again ${laterIn(error.retryAfterMs)}.`, + `You've added the most versions for today. Try again ${laterIn(error.retryAfterMs, "tomorrow")}.`, content_rejected: "This video can't be shared.", export_blocked: "Adding videos to review pages isn't available for this account.", feature_unavailable: "Review pages aren't available for your account yet.", @@ -38,9 +40,9 @@ export function versionSentence(error, fallback = "Couldn't add this version. Tr return fallback; } -/** "in about 3 hours", from the server's Retry-After. @param {number | undefined} ms */ -function laterIn(ms) { - if (!ms) return "tomorrow"; +/** "in about 3 hours", from the server's Retry-After; `unknown` when it sent none. @param {number | undefined} ms @param {string} unknown */ +function laterIn(ms, unknown) { + if (!ms) return unknown; const minutes = Math.ceil(ms / 60_000); if (minutes < 60) return `in ${minutes} minute${minutes === 1 ? "" : "s"}`; const hours = Math.round(minutes / 60); diff --git a/packages/share/tests/reviewVersionSentences.test.mjs b/packages/share/tests/reviewVersionSentences.test.mjs new file mode 100644 index 0000000000..81c296d882 --- /dev/null +++ b/packages/share/tests/reviewVersionSentences.test.mjs @@ -0,0 +1,29 @@ +import assert from "node:assert/strict"; +import { test } from "node:test"; +import { ReviewFailed } from "../src/reviewClient.mjs"; +import { versionSentence } from "../src/reviewVersionSentences.mjs"; + +test("the hourly version cap says how long to wait instead of telling the person to try again now", () => { + assert.equal( + versionSentence(new ReviewFailed(429, "export_hourly_limit", undefined, 25 * 60_000)), + "You've added the most versions for this hour. Try again in 25 minutes.", + ); +}); + +test("each cap falls back to its own window when the server sends no Retry-After", () => { + assert.equal( + versionSentence(new ReviewFailed(429, "export_hourly_limit")), + "You've added the most versions for this hour. Try again in an hour.", + ); + assert.equal( + versionSentence(new ReviewFailed(429, "export_daily_limit")), + "You've added the most versions for today. Try again tomorrow.", + ); +}); + +test("the daily version cap rounds a long wait to hours", () => { + assert.equal( + versionSentence(new ReviewFailed(429, "export_daily_limit", undefined, 2 * 60 * 60_000)), + "You've added the most versions for today. Try again in about 2 hours.", + ); +});