Skip to content

fix(packages,worker): add VAPI to ProviderName union and drop as any cast - #5745

Open
Harsh23Kashyap wants to merge 1 commit into
Helicone:mainfrom
Harsh23Kashyap:fix/vapi-provider-name-union
Open

fix(packages,worker): add VAPI to ProviderName union and drop as any cast#5745
Harsh23Kashyap wants to merge 1 commit into
Helicone:mainfrom
Harsh23Kashyap:fix/vapi-provider-name-union

Conversation

@Harsh23Kashyap

Copy link
Copy Markdown

Fixes #5744.

Summary

vapiProxyRouter calls proxyForwarder(requestWrapper, env, ctx, "VAPI" as any) with an as any cast because "VAPI" is missing from the ProviderName union at packages/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 through proxyForwarder, and heliconeProviderToModelProviderName returns null for "VAPI" via its existing default: return null; clause (same as today).

This is the type-hygiene follow-up to #5739 (which wired VAPI_PROXY to getVapiProxyRouter).

What changed

  • packages/cost/providers/mappings.ts: add "VAPI" to the providersNames array, after "CANOPYWAVE". One line. The ProviderName union 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 = ProviderName | "CUSTOM" | ModelProviderName (from worker/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, 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 (new) + worker/vitest.config.mts: register the new test project (mirrors the existing test/alerts node-env pattern).

Why the test is structural

The existing worker/test/ai-gateway vitest 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 the as any cast or removing "VAPI" from the union).

Cascades verified

The only switch on ProviderName in the repo is heliconeProviderToModelProviderName in packages/cost/models/provider-helpers.ts:25-86. Its default: return null; clause handles any new union member without an explicit case. The other two switch (provider) statements in packages/cost/ (getUsageProcessor at usage/getUsageProcessor.ts:16 and getThresholdValueFunction at models/calculate-cost.ts:115) operate on ModelProviderName (lowercase), which is a separate type and is not affected.

For "VAPI" the natural mapping in heliconeProviderToModelProviderName is null (no cost calculation, same as the unhandled default). Runtime cost behavior is unchanged.

Verified

  • npx tsc --noEmit -p worker/tsconfig.json — clean, no new errors
  • npx tsc --noEmit -p packages/tsconfig.json — same 3 pre-existing errors as on upstream/main; none introduced
  • cd worker && npx vitest run test/routers/vapiProviderName.spec.ts — 6 passed in 143ms
  • Reverting both source changes makes 3 of 6 tests fail, confirming regression detection works
  • Full worker vitest: 32 test files, 10 pass (including the new routers project), 22 fail to load with the pre-existing Cannot find module '@helicone-package/cost/costCalc' error; 149 tests run, all pass

Out of scope (deferred to follow-up issues)

  • Adding a cost model for VAPI in packages/cost/models/registry.ts and the providers array in packages/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 report null cost via the existing default: return null; clause.
  • Adding a host-routing block in worker/src/index.ts so a vapi.<helicone-domain> host dispatches to WORKER_TYPE: "VAPI_PROXY". Separate product decision.

Risk

Very low. The change is:

  • A new string in a const array.
  • Removal of an as any cast on a single call site.
  • A structural regression test.

Worst case: a switch without a default clause somewhere would now be non-exhaustive. The repo was searched for switches on ProviderName and provider; only the three documented above operate on these types, and all three either operate on a different type (ModelProviderName) or have a default clause.

…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.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Harsh23Kashyap is attempting to deploy a commit to the Helicone Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
vercel Bot temporarily deployed to Preview – helicone-bifrost July 29, 2026 20:24 Inactive
@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
helicone-bifrost Skipped Skipped Jul 29, 2026 8:24pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vapiProxyRouter forwards with "VAPI" as any because "VAPI" is missing from the ProviderName union

1 participant