fix(packages,worker): add VAPI to ProviderName union and drop as any cast - #5745
Open
Harsh23Kashyap wants to merge 1 commit into
Open
fix(packages,worker): add VAPI to ProviderName union and drop as any cast#5745Harsh23Kashyap wants to merge 1 commit into
Harsh23Kashyap wants to merge 1 commit into
Conversation
…cast vapiProxyRouter called proxyForwarder with 'VAPI' as any because the string was missing from the ProviderName union in packages/cost/providers/mappings.ts (the array ended at CANOPYWAVE). The cast hid the fact that the type system disagreed with the runtime value, and would have silently absorbed any future change to proxyForwarder's provider parameter type. This is the documented follow-up to Helicone#5739 (which wired VAPI_PROXY to getVapiProxyRouter). - packages/cost/providers/mappings.ts: add 'VAPI' to providersNames, one line, after CANOPYWAVE. ProviderName now includes 'VAPI'. - worker/src/routers/vapiProxyRouter.ts: drop the 'as any' cast on the proxyForwarder call. The literal 'VAPI' is now assignable to Provider. - worker/test/routers/vapiProviderName.spec.ts: 6 structural regression tests that read the two source files and assert 'VAPI' is in the union, the as any cast is gone, and the router still has the getVapiProxyRouter export and /helicone/test route (positive controls). - worker/test/routers/vitest.config.mts + worker/vitest.config.mts: register the new test project. Runtime behavior is unchanged. The only switch on ProviderName is heliconeProviderToModelProviderName in provider-helpers.ts:25-86, which has a 'default: return null;' clause that catches the new union member. For 'VAPI' the natural mapping is null (no cost calculation, same as the unhandled default). Fixes Helicone#5744.
Contributor
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
@Harsh23Kashyap is attempting to deploy a commit to the Helicone Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
This was referenced Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5744.
Summary
vapiProxyRoutercallsproxyForwarder(requestWrapper, env, ctx, "VAPI" as any)with anas anycast because"VAPI"is missing from theProviderNameunion atpackages/cost/providers/mappings.ts:97-135. This PR adds"VAPI"to the union and removes the cast. Runtime behavior is unchanged: VAPI requests still flow throughproxyForwarder, andheliconeProviderToModelProviderNamereturnsnullfor "VAPI" via its existingdefault: return null;clause (same as today).This is the type-hygiene follow-up to #5739 (which wired
VAPI_PROXYtogetVapiProxyRouter).What changed
packages/cost/providers/mappings.ts: add"VAPI"to theprovidersNamesarray, after"CANOPYWAVE". One line. TheProviderNameunion now includes"VAPI".worker/src/routers/vapiProxyRouter.ts: drop theas anycast on theproxyForwardercall. The literal"VAPI"is now assignable toProvider = ProviderName | "CUSTOM" | ModelProviderName(fromworker/src/index.ts:29).worker/test/routers/vapiProviderName.spec.ts(new): 6 structural regression tests that read the two source files and assert"VAPI"is in the union, theas anycast is gone, and the router still has thegetVapiProxyRouterexport and/helicone/testroute (positive controls).worker/test/routers/vitest.config.mts(new) +worker/vitest.config.mts: register the new test project (mirrors the existingtest/alertsnode-env pattern).Why the test is structural
The existing
worker/test/ai-gatewayvitest config has a pre-existing module-resolution error (Cannot find module '@helicone-package/cost/costCalc') that blocks any test whose import chain touches the worker source from loading. A structural (file-read) check runs in any environment and directly enforces the class of bug this PR fixes (someone re-introducing theas anycast or removing"VAPI"from the union).Cascades verified
The only
switchonProviderNamein the repo isheliconeProviderToModelProviderNameinpackages/cost/models/provider-helpers.ts:25-86. Itsdefault: return null;clause handles any new union member without an explicit case. The other twoswitch (provider)statements inpackages/cost/(getUsageProcessoratusage/getUsageProcessor.ts:16andgetThresholdValueFunctionatmodels/calculate-cost.ts:115) operate onModelProviderName(lowercase), which is a separate type and is not affected.For "VAPI" the natural mapping in
heliconeProviderToModelProviderNameisnull(no cost calculation, same as the unhandleddefault). Runtime cost behavior is unchanged.Verified
npx tsc --noEmit -p worker/tsconfig.json— clean, no new errorsnpx tsc --noEmit -p packages/tsconfig.json— same 3 pre-existing errors as onupstream/main; none introducedcd worker && npx vitest run test/routers/vapiProviderName.spec.ts— 6 passed in 143msroutersproject), 22 fail to load with the pre-existingCannot find module '@helicone-package/cost/costCalc'error; 149 tests run, all passOut of scope (deferred to follow-up issues)
packages/cost/models/registry.tsand theprovidersarray inpackages/cost/providers/mappings.ts:141+. Requires knowing the VAPI upstream URL, the model, and per-token pricing. This PR does not change cost behavior; VAPI requests still reportnullcost via the existingdefault: return null;clause.worker/src/index.tsso avapi.<helicone-domain>host dispatches toWORKER_TYPE: "VAPI_PROXY". Separate product decision.Risk
Very low. The change is:
constarray.as anycast on a single call site.Worst case: a switch without a
defaultclause somewhere would now be non-exhaustive. The repo was searched for switches onProviderNameandprovider; only the three documented above operate on these types, and all three either operate on a different type (ModelProviderName) or have adefaultclause.