Skip to content

Commit 8a15d9f

Browse files
terencechoclaude
andauthored
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 <[email protected]>
1 parent 5a88c99 commit 8a15d9f

2 files changed

Lines changed: 35 additions & 4 deletions

File tree

‎packages/share/src/reviewVersionSentences.mjs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ const SAID = {
1111
export_too_large: "This video is over 2 GB, the most a review page takes. Export a smaller one.",
1212
export_too_long:
1313
"This video is over 30 minutes, the most a review page takes. Export a shorter one.",
14+
export_hourly_limit: (error) =>
15+
`You've added the most versions for this hour. Try again ${laterIn(error.retryAfterMs, "in an hour")}.`,
1416
export_daily_limit: (error) =>
15-
`You've added the most versions for today. Try again ${laterIn(error.retryAfterMs)}.`,
17+
`You've added the most versions for today. Try again ${laterIn(error.retryAfterMs, "tomorrow")}.`,
1618
content_rejected: "This video can't be shared.",
1719
export_blocked: "Adding videos to review pages isn't available for this account.",
1820
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
3840
return fallback;
3941
}
4042

41-
/** "in about 3 hours", from the server's Retry-After. @param {number | undefined} ms */
42-
function laterIn(ms) {
43-
if (!ms) return "tomorrow";
43+
/** "in about 3 hours", from the server's Retry-After; `unknown` when it sent none. @param {number | undefined} ms @param {string} unknown */
44+
function laterIn(ms, unknown) {
45+
if (!ms) return unknown;
4446
const minutes = Math.ceil(ms / 60_000);
4547
if (minutes < 60) return `in ${minutes} minute${minutes === 1 ? "" : "s"}`;
4648
const hours = Math.round(minutes / 60);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import assert from "node:assert/strict";
2+
import { test } from "node:test";
3+
import { ReviewFailed } from "../src/reviewClient.mjs";
4+
import { versionSentence } from "../src/reviewVersionSentences.mjs";
5+
6+
test("the hourly version cap says how long to wait instead of telling the person to try again now", () => {
7+
assert.equal(
8+
versionSentence(new ReviewFailed(429, "export_hourly_limit", undefined, 25 * 60_000)),
9+
"You've added the most versions for this hour. Try again in 25 minutes.",
10+
);
11+
});
12+
13+
test("each cap falls back to its own window when the server sends no Retry-After", () => {
14+
assert.equal(
15+
versionSentence(new ReviewFailed(429, "export_hourly_limit")),
16+
"You've added the most versions for this hour. Try again in an hour.",
17+
);
18+
assert.equal(
19+
versionSentence(new ReviewFailed(429, "export_daily_limit")),
20+
"You've added the most versions for today. Try again tomorrow.",
21+
);
22+
});
23+
24+
test("the daily version cap rounds a long wait to hours", () => {
25+
assert.equal(
26+
versionSentence(new ReviewFailed(429, "export_daily_limit", undefined, 2 * 60 * 60_000)),
27+
"You've added the most versions for today. Try again in about 2 hours.",
28+
);
29+
});

0 commit comments

Comments
 (0)