Repository navigation
Grant meter credits from the runtime SDK - #15423
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
All reported issues were addressed across 15 files
This PR changes payment, billing, or quota logic. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Adds a runtime SDK grant API and demo survey flow that grants meter credits without a purchase. This is a new public billing capability with financial/product tradeoffs (default rollover, idempotency, member-actor semantics) that need human sign-off.
View guided diff | Turn on auto-fix | Re-trigger cubic
0da7fe6 to
c520262
Compare
There was a problem hiding this comment.
1 issue found across 5 reviewed files. 19 files intentionally excluded from review.
Confidence score: 3/5
- The global meter lookup in
customer-meters.tscan reject a valid meter when another accessible organization has the same ID, even thoughcustomer_ididentifies the intended organization. Resolve the meter within that organization.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="clients/packages/polar/src/internal/api/customer-meters.ts">
<violation number="1" location="clients/packages/polar/src/internal/api/customer-meters.ts:24">
P2: This global lookup rejects duplicate meter IDs across accessible organizations even though `customer_id` identifies the customer's organization. Resolve the meter within that organization, as the external-ID credit endpoint does.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| } | ||
| // Polar IDs and external IDs can't be mixed in one credit request | ||
| if ('customer_id' in identifier) { | ||
| const meter = await getDeployedMeter(sdk, externalMeterId) |
There was a problem hiding this comment.
P2: This global lookup rejects duplicate meter IDs across accessible organizations even though customer_id identifies the customer's organization. Resolve the meter within that organization, as the external-ID credit endpoint does.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At clients/packages/polar/src/internal/api/customer-meters.ts, line 24:
<comment>This global lookup rejects duplicate meter IDs across accessible organizations even though `customer_id` identifies the customer's organization. Resolve the meter within that organization, as the external-ID credit endpoint does.</comment>
<file context>
@@ -13,13 +14,26 @@ export const creditCustomerMeter = async (
+ }
+ // Polar IDs and external IDs can't be mixed in one credit request
+ if ('customer_id' in identifier) {
+ const meter = await getDeployedMeter(sdk, externalMeterId)
+ return sdk.customerMeters.credits({
+ ...identifier,
</file context>
There was a problem hiding this comment.
All reported issues were addressed across 4 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
1 existing issue remains and no new issues found across 5 files (changes from recent commits).
Confidence score: 3/5
getDeployedMeterIdinclients/packages/polar/src/client/actor.tscan reject an external-customer grant when the meter ID exists in multiple accessible organizations, even though the credits endpoint resolvesexternal_meter_id. Align the meter lookup with that resolution so valid grants aren’t rejected.
Requires human review: Auto-approval blocked by 4 unresolved issues from previous reviews.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Auto-approval blocked by 2 unresolved issues from previous reviews.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Auto-approval blocked by 2 unresolved issues from previous reviews.
View guided diff | Turn on auto-fix | Re-trigger cubic
03cb5b6 to
7fffb70
Compare
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
7362c80 to
a39458a
Compare
There was a problem hiding this comment.
No issues found across 13 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Adds a new public grant SDK operation and a demo flow that repeatedly grants credits without idempotency; the main human judgment is approving this new credit-granting API and the demo's unlimited-repeat behavior.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.
View guided diff | Turn on auto-fix | Re-trigger cubic
Stacked on #15420. Uses the credits endpoint from #15405 and first requires #15440 to be merged.
Adds
grantto the runtime SDK actor, so a merchant can give a customer credits from their server without a purchase:rolloverdefaults to true.idempotencyKeymaps to the endpoint'sexternal_id, so retrying doesn't grant twice.balance()reportspristine: falseuntil the credit is applied.The demo app shows: a free customer who runs out of tool calls can answer "What are you building?" to get 10 tool calls instead of upgrading. The code panel has a new Grant step.