Skip to content

fix(perplexity): handle missing group in API response#462

Open
malhobayyeb wants to merge 1 commit into
robinebers:mainfrom
malhobayyeb:fix-perplexity-api-change
Open

fix(perplexity): handle missing group in API response#462
malhobayyeb wants to merge 1 commit into
robinebers:mainfrom
malhobayyeb:fix-perplexity-api-change

Conversation

@malhobayyeb
Copy link
Copy Markdown

@malhobayyeb malhobayyeb commented May 11, 2026

Fixes #278.

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.

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 /groups responses for Perplexity PRO users. Read the plan from /api/user and keep the integration working when rate-limit data is available even without a group.

  • Bug Fixes
    • Fetch user from /api/user and use subscription_tier in detectPlanLabel as a fallback.
    • Only fetch group details and usage analytics when a groupId exists.
    • Relax connection check to proceed if user or rateLimits are present when group is missing.
    • Guard balance and usage reads when group is null.

Written for commit d98e71d. Summary will update on new commits.

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.
Copilot AI review requested due to automatic review settings May 11, 2026 04:31
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@malhobayyeb
Copy link
Copy Markdown
Author

CleanShot 2026-05-11 at 07 32 48

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/user when group customerInfo is 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
@validatedev
Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perplexity not showing

3 participants