From 02f097880db473f9c3370d7a63cfb2b3c941f968 Mon Sep 17 00:00:00 2001 From: luulam Date: Tue, 8 Sep 2026 10:36:24 +0700 Subject: [PATCH] fix(merge): restore ANTHROPIC_COMPATIBLE_PREFIX import + drop dead appendRequestLog call Full-source eslint no-undef sweep over src/ + open-sse/ (config listing node/web globals) found two remaining undeclared-variable regressions of the same merge-loss family: * api/providers/test-batch: branch commit f0adfb20 added a providerId.startsWith(ANTHROPIC_COMPATIBLE_PREFIX) check but never imported it; the master merge kept the buggy line. Every batch test / provider-group filter touching a non-openai-compatible provider threw ReferenceError (|| does not short-circuit). * utils/stream.js finalizeStream: no-usage fallback called appendRequestLog(), a stub upstream had marked no-op and whose export chain was dropped by the merge. The call site only fires when a stream ends without valid usage and now threw ReferenceError inside the terminal callback. Removed the dead call (behaviour identical: the stub wrote nothing). All other no-undef reports are browser globals absent from the scan config, not source bugs. next build --webpack passes; smoke server boots and auth-rejects unauthenticated /v1 + /api traffic as expected; unit suite 1746 pass / 103 fail (was 1738/111). --- open-sse/utils/stream.js | 5 +++-- src/app/api/providers/test-batch/route.js | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/open-sse/utils/stream.js b/open-sse/utils/stream.js index 6557cd15..2115fef3 100644 --- a/open-sse/utils/stream.js +++ b/open-sse/utils/stream.js @@ -98,9 +98,10 @@ export function createSSEStream(options = {}) { if (hasValidUsage(finalUsage)) { logUsage(isPassthrough ? provider : (state?.provider || targetFormat), finalUsage, model, connectionId, apiKey); - } else { - appendRequestLog({ model, provider, connectionId, tokens: null, status: "200 OK" }).catch(() => { }); } + // No else branch: the old appendRequestLog() fallback was a no-op stub + // (request log is derived from usageHistory on read) and was dropped by + // the master merge; logging a 200 with tokens:null was a cosmetic entry. if (onStreamComplete) { onStreamComplete({ diff --git a/src/app/api/providers/test-batch/route.js b/src/app/api/providers/test-batch/route.js index 7f055420..2a45c414 100644 --- a/src/app/api/providers/test-batch/route.js +++ b/src/app/api/providers/test-batch/route.js @@ -6,6 +6,7 @@ import { OAUTH_PROVIDERS, APIKEY_PROVIDERS, OPENAI_COMPATIBLE_PREFIX, + ANTHROPIC_COMPATIBLE_PREFIX, } from "@/shared/constants/providers"; import { testSingleConnection } from "../[id]/test/testUtils.js";