Skip to content

Commit 2b6c291

Browse files
fixfonclaudejuliusmarminge
authored
fix(server): a Claude account with no rate-limit data no longer stays unsupported (pingdotgg#18624)
Co-authored-by: Claude Sonnet 5.5 <[email protected]> Co-authored-by: Julius Marminge <[email protected]>
1 parent 4a6cd8d commit 2b6c291

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

‎apps/server/src/provider/claudeUsageLimits.test.ts‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,23 @@ describe("claudeUsageResponseToLimits", () => {
8686
).toEqual({ overageIncluded: "Fable" });
8787
});
8888

89-
it("reports API key and Bedrock accounts as unsupported", () => {
90-
expect(
91-
claudeUsageResponseToLimits({
92-
checkedAt,
93-
response: { rate_limits_available: false, rate_limits: null },
94-
}).limits,
95-
).toEqual({ checkedAt, windows: [], unavailable: { reason: "unsupported" } });
96-
});
89+
it.each([
90+
{ rateLimitsAvailable: false, reason: "unsupported" },
91+
{ rateLimitsAvailable: true, reason: "probeFailed" },
92+
])(
93+
"reports null usage as $reason when availability is $rateLimitsAvailable",
94+
({ rateLimitsAvailable, reason }) => {
95+
expect(
96+
claudeUsageResponseToLimits({
97+
checkedAt,
98+
response: { rate_limits_available: rateLimitsAvailable, rate_limits: null },
99+
}),
100+
).toEqual({
101+
limits: { checkedAt, windows: [], unavailable: { reason } },
102+
names: noNames,
103+
});
104+
},
105+
);
97106

98107
it("skips a window the endpoint reports without a utilization", () => {
99108
expect(

‎apps/server/src/provider/claudeUsageLimits.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ export function claudeUsageResponseToLimits(input: {
142142
const { response, checkedAt } = input;
143143
if (!response.rate_limits_available || !response.rate_limits) {
144144
return {
145-
limits: makeUnavailableUsageLimits({ checkedAt, reason: "unsupported" }),
145+
limits: makeUnavailableUsageLimits({
146+
checkedAt,
147+
reason: response.rate_limits_available ? "probeFailed" : "unsupported",
148+
}),
146149
names: { overageIncluded: undefined },
147150
};
148151
}

0 commit comments

Comments
 (0)