Skip to content

Commit 5ca04d3

Browse files
jahoomaclaude
andcommitted
Show upgrade-required error to old freebuff clients
When the waiting-room gate rejects a free-mode request and no freebuff_instance_id was sent, return 426 with a "please restart to upgrade" message. Old CLI versions render the message verbatim in their error banner; new clients still get the normal gate responses. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0204a37 commit 5ca04d3

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

  • web/src/app/api/v1/chat/completions

web/src/app/api/v1/chat/completions/_post.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,32 @@ export async function postChatCompletions(params: {
410410
// Runs before the rate limiter so rejected requests don't burn a queued
411411
// user's free-mode counters.
412412
if (isFreeModeRequest) {
413+
const claimedInstanceId =
414+
typedBody.codebuff_metadata?.freebuff_instance_id
413415
const gate = await checkSession({
414416
userId,
415-
claimedInstanceId: typedBody.codebuff_metadata?.freebuff_instance_id,
417+
claimedInstanceId,
416418
})
417419
if (!gate.ok) {
420+
// Old freebuff clients (pre-waiting-room) never send an instance_id.
421+
// Return a 426 with a clear "please restart to upgrade" message that
422+
// their existing error banner will render verbatim.
423+
if (!claimedInstanceId) {
424+
trackEvent({
425+
event: AnalyticsEvent.CHAT_COMPLETIONS_VALIDATION_ERROR,
426+
userId,
427+
properties: { error: 'freebuff_update_required' },
428+
logger,
429+
})
430+
return NextResponse.json(
431+
{
432+
error: 'freebuff_update_required',
433+
message:
434+
'This version of freebuff is out of date. Please restart freebuff to upgrade and continue using free mode.',
435+
},
436+
{ status: 426 },
437+
)
438+
}
418439
trackEvent({
419440
event: AnalyticsEvent.CHAT_COMPLETIONS_VALIDATION_ERROR,
420441
userId,

0 commit comments

Comments
 (0)