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 <noreply@anthropic.com>
This commit is contained in:
terencecho
2026-11-11 04:49:44 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 5a88c9938e
commit 8a15d9feed
2 changed files with 35 additions and 4 deletions
@@ -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);
@@ -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.",
);
});