fix(perplexity): handle missing group in API response#462
Conversation
Perplexity changed their API to return an empty list from the /groups endpoint for regular PRO users. This fix modifies the plugin to fetch the user plan from the /api/user endpoint instead, preventing a total connection failure, and allows the flow to proceed without a group object if rate limit data is available.
There was a problem hiding this comment.
Pull request overview
This PR updates the Perplexity plugin to tolerate Perplexity’s API change where /groups may return an empty list for regular PRO users, by fetching plan details from /api/user and allowing the probe flow to proceed when group data is missing but rate-limit data is available.
Changes:
- Extend plan detection to fall back to
/api/userwhen groupcustomerInfois unavailable. - Make group and usage-analytics fetching conditional on the presence of a group id instead of hard-failing.
- Relax the “Unable to connect” guard so the plugin can still render rate-limit lines without a group object.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const authToken = session && session.authToken | ||
| if (!authToken) return null | ||
| const restHeaders = makeRestHeaderOverrides(session) | ||
| const user = fetchJsonOptional(ctx, LOCAL_USER_ENDPOINT, authToken, restHeaders) |
| const restState = fetchRestState(ctx, session) | ||
| if (!restState || !restState.group) throw "Unable to connect. Try again later." | ||
| if (!restState || (!restState.group && !restState.user && !restState.rateLimits)) throw "Unable to connect. Try again later." | ||
|
|
||
| const customerInfo = restState.group && restState.group.customerInfo | ||
| const plan = detectPlanLabel(customerInfo) | ||
| const plan = detectPlanLabel(customerInfo, restState.user) | ||
|
|
||
| const dollarLines = [] | ||
| const balanceUsd = readBalanceUsd(restState.group) | ||
| const balanceUsd = restState.group ? readBalanceUsd(restState.group) : null |
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@copilot review Addressed the two open Copilot threads:
Verification:
|
|
Update after final quality gating:
cubic previously reported no issues on the earlier PR revision. This comment asks Copilot and Codex for a follow-up review of the current head. |
|
To use Codex here, create a Codex account and connect to github. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
validatedev
left a comment
There was a problem hiding this comment.
Looks good and clean to me. Approved, thanks!

Fixes #278.
Perplexity changed their API to return an empty list from the
/groupsendpoint for regular PRO users. This fix modifies the plugin to fetch the user plan from the/api/userendpoint instead, preventing a total connection failure, and allows the flow to proceed without a group object if rate limit data is available.Visual Verification:
A screenshot demonstrating the successful fix (showing the rate limit details without the 'Unable to connect' error) has been provided and verified locally.
🤖 Generated with Gemini CLI
Summary by cubic
Handle empty
/groupsresponses for Perplexity PRO users by reading the plan from/api/user(with a trailing-slash fallback) and continuing when rate-limit data exists without a group. Adds tests to cover this flow.userfrom/api/useror/api/user/and usesubscription_tierindetectPlanLabelas a fallback.groupIdexists.userorrateLimitsare present whengroupis missing.groupis null.Written for commit f5707e7. Summary will update on new commits.