Repository navigation
InsufficientBalanceError for 403 INSUFFICIENT_BALANCE; free plan 401 docs - #45
quantumdark wants to merge 6 commits into
Conversation
…equest only asks to top up
| ``` | ||
|
|
||
| `AuthenticationError`, `PlanAccessError`, `NotFoundError`, `ServerError`, and `APIConnectionError` cover the rest. Transient failures are retried automatically (3 attempts by default). | ||
| `AuthenticationError`, `PlanAccessError`, `NotFoundError`, `ServerError`, and `APIConnectionError` cover the rest. A request the account's remaining balance cannot cover raises `InsufficientBalanceError` (a `PlanAccessError`), whose `max_affordable_records` is the largest size that would fit, counted in the request's own unit (the message names it: records, contacts, domains, rows, queries or personas). Transient failures are retried automatically (3 attempts by default). |
There was a problem hiding this comment.
max_affordable_records is not always a size that fits. The new exception documentation says it can be 0 when even the request fee exceeds the balance. Single-company and single-email requests also cannot be made smaller. A caller following this advice could retry with zero records and get another error.
Qualify the advice here and in CHANGELOG.md: retry smaller only when the request supports it and the value is positive; otherwise top up.
Prompt To Fix With AI
This is a comment left during a code review.
Path: README.md
Line: 373
Comment:
**Retry advice misses zero**
`max_affordable_records` is not always a size that fits. The new exception documentation says it can be `0` when even the request fee exceeds the balance. Single-company and single-email requests also cannot be made smaller. A caller following this advice could retry with zero records and get another error.
Qualify the advice here and in `CHANGELOG.md`: retry smaller only when the request supports it and the value is positive; otherwise top up.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
|
||
| ## Unreleased | ||
|
|
||
| - SDK/CLI: new accounts start on the free plan ($5.00 of usage a month at pay-as-you-go rates, no card), and a request with no credentials now gets a 401 whose `detail` is an object (`code: "UNAUTHENTICATED"`, `message`, `signup_url`, `plan`, `allowance_usd`, `cpc`, `cpm`) pointing at free signup. The SDK raises `AuthenticationError` with the server's `message`, as for any object `detail`; other 401s keep a string `detail`. No SDK code change; older versions show the JSON body as the message. |
There was a problem hiding this comment.
The claim “No SDK code change” contradicts this PR. _extract_message gains the object-detail branch that makes AuthenticationError use the server's message; older versions fall back to the JSON body. Remove that claim so readers know the readable message requires the updated SDK.
Prompt To Fix With AI
This is a comment left during a code review.
Path: CHANGELOG.md
Line: 5
Comment:
**SDK change is denied**
The claim “No SDK code change” contradicts this PR. `_extract_message` gains the object-`detail` branch that makes `AuthenticationError` use the server's `message`; older versions fall back to the JSON body. Remove that claim so readers know the readable message requires the updated SDK.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Raises
InsufficientBalanceErrorfor a 403INSUFFICIENT_BALANCE(reports what fits /max_affordable_records), and documents the free plan and the no-credentials 401 object (signup_urlkept).Ships with the #235 platform main release (discolike-platform !993 → !996). Release the SDK after the platform rollout.
The code appears safe to merge, with two non-blocking documentation corrections.
Fix with agent prompt
Summary
Adds
InsufficientBalanceErrorfor 403 responses carryingINSUFFICIENT_BALANCE, while keeping it catchable asPlanAccessError.Reviews (1) · Last reviewed commit: "docs(sdk): max_affordable_records is 0 w..." · Reviewed by Greptile