fix(perplexity): handle missing group in API response#462
Open
malhobayyeb wants to merge 1 commit into
Open
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.
Author
Contributor
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) |
Comment on lines
395
to
+402
| 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 |
Collaborator
|
@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". |
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.

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. Read the plan from/api/userand keep the integration working when rate-limit data is available even without a group.userfrom/api/userand usesubscription_tierindetectPlanLabelas a fallback.groupIdexists.userorrateLimitsare present whengroupis missing.groupis null.Written for commit d98e71d. Summary will update on new commits.