Skip to content

fix(pricing): accept the dsh provider in PricingProviderSchema - #1652

Merged
tarasyarema merged 2 commits into
desplega-ai:mainfrom
drakeo338:claude/1636-fix
Sep 28, 2026
Merged

tarasyarema merged 2 commits into
desplega-ai:mainfrom
drakeo338:claude/1636-fix

Conversation

@drakeo338

Copy link
Copy Markdown

Intent

Fixes #1636.

dsh was added to ProviderNameSchema but never to PricingProviderSchema, so POST /api/pricing/dsh/{model}/{tokenClass} returns 400 and a dsh session-cost row is rejected the same way acp was before it got added.

Repro

  1. On origin/main, run: bun -e 'import {ProviderNameSchema, PricingProviderSchema} from "./src/types"; console.log(PricingProviderSchema.safeParse("dsh").success)'.
  2. Output is false; ProviderNameSchema accepts dsh but PricingProviderSchema does not.

Setup

  • Commit: merge-base bd6074f, fix on top at f533328.
  • No deployment-specific setup; the bug reproduces on any checkout.

Decisions & trade-offs

Made session-data.ts's POST /api/session-costs provider field reuse PricingProviderSchema instead of its own inline enum, so the two lists cannot drift apart again. No other side effects: no migration, no new config.

Proof of work

  • bun test src/tests/pricing-routes.test.ts src/tests/provider-registration.test.ts on merge-base bd6074f (upstream/main) with this PR's test files overlaid: 21 passed, 2 failed (the two new dsh assertions).
  • Same command on f533328 (this branch's HEAD): 23 passed, 0 failed.

Urgency

  • asap
  • this week
  • nice to have

PricingProviderSchema (src/types.ts) forgot dsh when it was added to
ProviderNameSchema, so POST /api/pricing/dsh/{model}/{tokenClass} 400ed
and a dsh session-cost POST was rejected by the same inline enum in
src/http/session-data.ts — an operator could not record a dsh price row
or have dsh usage costed at all.

Add dsh to PricingProviderSchema (acp sets the precedent for accepting
a provider without seeded rate rows) and have session-data.ts's
provider field on POST /api/session-costs import and reuse that schema
instead of hand-duplicating the enum, so the two lists can't drift
again. Also add the now-required dsh entry to pricing-normalize.ts's
per-provider Record (no-op, same as claude/devin/gemini). Regenerate
openapi.json and docs-site/public/openapi.d.ts.

Closes desplega-ai#1636
@vercel

vercel Bot commented Sep 28, 2026

Copy link
Copy Markdown

@drakeo338 is attempting to deploy a commit to the Desplega Labs Team on Vercel.

A member of the Team first needs to authorize it.

@desplega-bot

Copy link
Copy Markdown
Contributor

Verdict: changes needed for CI; the API fix is sound.

Reviewed full diff bd6074f...f533328.

Standards

No introduced code-quality findings. Reusing PricingProviderSchema removes duplicated validation.

Specification

  • src/types.ts:3312 accepts dsh. The replacement at src/http/session-data.ts:215 preserves all eight previous values: claude, claude-managed, codex, pi, opencode, devin, gemini, and acp. The field remains optional.
  • No database migration is needed. Migration 046's pricing-provider CHECK was removed by src/be/migrations/063_cost_context_schema_relax.sql:32. The resulting session_costs table has no provider column or provider CHECK.
  • Remaining omissions are pre-existing follow-ups, not regressions in this API fix: apps/ui/src/api/types.ts:2509 and apps/ui/src/pages/budgets/page.tsx:208 still allow only claude|codex|pi, so the dashboard cannot add a dsh price. src/providers/types.ts:49 also omits dsh from CostData.provider; address that before the adapter starts emitting costs.
  • seed-pricing.ts does not validate incoming provider values; no dsh rates are seeded, and the registration test intentionally exempts dsh and acp. Custom rates can be added through the API. The new normalization-map entry supports their lookup.
  • Both regression tests exist and pass: bun test src/tests/pricing-routes.test.ts src/tests/provider-registration.test.ts → 23 pass, 0 fail. bun run tsc:check passes. bun run docs:openapi produces no tracked changes; both openapi.json and docs-site/public/openapi.d.ts include dsh.

Required CI follow-up

Run Tests (1/2) fails with six unhandled UI import errors: Cannot find module '@/components/ui/spinner' from apps/ui/src/components/ui/button.tsx. These are outside this diff, but Merge Gate consequently fails. Resolve the test/module-resolution failure and obtain a green gate before merge.

The live main-branch rules require Merge Gate only. The five Vercel authorization failures are cosmetic fork-preview failures, not required checks. No held action_required workflow runs were found. Test shard 2, lint/type checks, E2E Contract, and OpenAPI freshness pass.

@desplega-bot

Copy link
Copy Markdown
Contributor

The six spinner module-resolution failures in Run Tests (1/2) are fixed on main by #1650 (merged). This branch is behind main (base bd6074f predates it), so updating the branch from main should clear Run Tests (1/2) and Merge Gate.

@tarasyarema
tarasyarema added this pull request to the merge queue Sep 28, 2026
Merged via the queue into desplega-ai:main with commit e9e85e6 Sep 28, 2026
29 of 34 checks passed
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.

dsh provider is missing from PricingProviderSchema and the session-costs provider enum, so its price and cost rows 400

3 participants