Dashboard › Code › LOREAI-GATEWAY-1E: resp.usage undefined…
019e69f0-a05a-7d48-8e35-76baf13533c5| Project | Hits | Last recalled |
|---|---|---|
| opencode-lore | 11 | 13h ago |
| opencode | 1 | 8d ago |
Trap: GatewayUsage typed as non-optional on GatewayResponse, so resp.usage.inputTokens looks safe. But resp.usage can be undefined at runtime (e.g., vLLM returning partial response). All four accumulators construct usage with ?? 0 guards on individual fields — but resp.usage itself can still be undefined if an exception produces a partial response object. Crash sites: pipeline.ts lines 2069, 2101, 2137-2140, 2150-2153, 2204-2206, 2282-2285, 2341, 2363, 2402; also buildOpenAINonStreamResponse (openai.ts:296-300). Fix: add const usage = resp.usage ?? { inputTokens: 0, outputTokens: 0, cacheReadInputTokens: 0, cacheCreationInputTokens: 0 } guard at top of postResponse() and nonStreamHttpResponse(), then use usage.* throughout.