Repository navigation
fix(billing): unify Upstash and Vercel KV credential resolution - #2686
Merged
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
✅ E2E Test Results: ALL TESTS PASSED
Test Output |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The KV credential test does not verify the constructor URL and token, so it could miss a regression that enables the client with unset credentials.
1 open issue
What changed in this PR
Unifies Upstash REST credential handling in UVAI’s web app so rate limiting and billing/telemetry stores accept Vercel Marketplace KV_REST_API_* credentials, addressing #2685.
Changes:
- Adds a shared Redis client factory backed by the existing credential resolver.
- Migrates the proxy and four stores without changing billing or quota policies.
- Adds KV-only regression coverage and test environment isolation.
| File | Description |
|---|---|
apps/web/src/proxy.ts |
Uses shared credential resolution for distributed rate limiting. |
apps/web/src/lib/billing/upstash-client.ts |
Adds the shared Upstash REST client factory. |
apps/web/src/lib/billing/kaizen-trace.ts |
Uses the shared factory for trace storage. |
apps/web/src/lib/billing/entitlement-store.ts |
Replaces duplicate client construction with the factory. |
apps/web/src/lib/billing/checkout-session-store.ts |
Enables KV credentials for checkout activation storage. |
apps/web/src/lib/billing/chat-quota.ts |
Enables KV credentials for distributed quota counting. |
apps/web/src/lib/billing/__tests__/upstash-kv-parity.test.ts |
Tests KV credential use across billing and telemetry stores. |
apps/web/src/__tests__/proxy-auth-gate.test.ts |
Adds KV-only proxy coverage and environment isolation. |
Review effort: Max
Contributor
✅ E2E Test Results: ALL TESTS PASSED
Test Output |
Owner
Author
|
Updated |
This branch was successfully deployed
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.

Canonical issue
Closes #2685
Outcome
Ensures
apps/web/src/proxy.ts(edge rate limiting) and the remaining billing/telemetry stores (chat-quota.ts,checkout-session-store.ts,kaizen-trace.ts) resolve bothUPSTASH_REDIS_REST_*and Vercel MarketplaceKV_REST_API_*credentials identically tovideo-pack-store.ts,video-pack-admission.ts,entitlement-store.ts, andorigin-gate-store.ts.Scope
apps/web/src/lib/billing/upstash-client.ts(createUpstashRedisClient()) backed byresolveUpstashRedisCredentials()apps/web/src/proxy.ts,chat-quota.ts,checkout-session-store.ts,kaizen-trace.ts, andentitlement-store.tsto reusecreateUpstashRedisClient()/resolveUpstashRedisCredentials()apps/web/src/lib/billing/__tests__/upstash-kv-parity.test.tsand addedKV_REST_API_*isolation + coverage inapps/web/src/__tests__/proxy-auth-gate.test.ts402billing/quota gates,TEMP_PAYWALL_OFF, pricing, or production secrets/env varsRisk
KV_REST_API_*variables are misconfigured in production, Upstash REST client calls will fail the same wayUPSTASH_REDIS_REST_*would (paid AI routes inproxy.tsremain fail-closed503).b1110c7a5(git revert b1110c7a5).Verification
Verified on commit
b1110c7a5in clean worktree:npx vitest run src/__tests__/proxy-auth-gate.test.ts src/lib/billing/__tests__/upstash-kv-parity.test.ts src/lib/billing/__tests__/entitlement-store.test.ts src/lib/billing/__tests__/checkout-session-store.test.ts src/lib/__tests__/video-pack-store.test.ts src/lib/__tests__/video-pack-admission.test.ts src/__tests__/test-env-isolation.test.ts: 7 test files passed (62 passed, 1 skipped invideo-pack-store.test.ts)npx tsc --noEmit: passed (0 errors)npx eslint ...on all 8 touched files: passed (0 errors/warnings)Focused tests
Required CI
Review threads resolved
Production evidence
Not yet deployed; awaiting CI and Vercel preview on this PR.
Agent handoff