Merged
Conversation
…domains Add credit eligibility configuration to llm_gateway_config table via three new columns: credit_eligible_domains, credit_eligible_email_domains and allow_localhost_credit. Free prepaid credit ($2) is now only granted when the meshUrl hostname or user email domain matches the configured lists. Unprovisioned key fallback in GATEWAY_CREDITS now returns $0 instead of the default prepaid limit. Made-with: Cursor
…igibility For non-localhost meshUrls, only the domain match against creditEligibleDomains is needed. Email is only checked when allowLocalhostCredit is true, to restrict localhost access to known team members. Made-with: Cursor
🚀 Preview Deployments Ready!Your changes have been deployed to preview environments: 📦
|
- Compute isEligibleForCredit once in provisionOrReuseKey and pass the resolved initialLimit to createOpenRouterKey, eliminating the redundant second eligibility call and preventing any TOCTOU divergence between key creation and the subsequent updateKeyLimit call - Redact userEmail from logs (PII); replaced with hasEmail boolean - ensureKeyLimitMatchesBillingMode now respects eligibility when recovering a prepaid key with a missing limit (was granting the default $2 credit unconditionally) - isEligibleForCredit: add ::1 (IPv6 loopback) to localhost detection and normalise all domain comparisons to lowercase Made-with: Cursor
Contributor
There was a problem hiding this comment.
1 issue found across 3 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="deco-ai-gateway/server/lib/constants.ts">
<violation number="1" location="deco-ai-gateway/server/lib/constants.ts:38">
P1: IPv6 localhost detection is incorrect: URL.hostname for loopback is `[::1]`, so this check misses localhost requests and applies the wrong credit eligibility path.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…brackets Made-with: Cursor
Contributor
There was a problem hiding this comment.
2 issues found across 6 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="deco-ai-gateway/server/db/schema.sql">
<violation number="1" location="deco-ai-gateway/server/db/schema.sql:390">
P2: The migration condition checks only one column before adding three, so partially migrated databases can miss required columns. Make each added column idempotent independently (or use `ADD COLUMN IF NOT EXISTS`).</violation>
</file>
<file name="deco-ai-gateway/server/lib/provisioning.ts">
<violation number="1" location="deco-ai-gateway/server/lib/provisioning.ts:242">
P2: The `isEligibleForCredit` check and limit computation duplicate the exact logic performed in `createOpenRouterKey`. Consider computing the limit once and passing it as an argument, or returning it from `createOpenRouterKey` to avoid duplicate logic.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…r column and remove redundant updateKeyLimit - Replace DO $$ block (single column check) with ADD COLUMN IF NOT EXISTS for each eligibility column independently; partial migrations can no longer leave the schema in an inconsistent state - Remove the redundant updateKeyLimit call after createOpenRouterKey: the key is already created with defaultLimit in the POST body, so the subsequent PATCH was an unnecessary extra API round-trip with identical values - Remove unused updateKeyLimit / LimitReset imports Made-with: Cursor
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.
Summary by cubic
Restricts free prepaid credit to eligible domains and defaults new prepaid keys to $0 unless the domain (and for localhost, email) qualifies. Hardens checks (incl. “[::1]”), redacts PII, fixes missing-limit recovery to respect eligibility, makes the migration idempotent, and removes a redundant key limit API call.
New Features
Migration
Written for commit a66e329. Summary will update on new commits.