Skip to content

Surface malformed plugin index errors#197

Merged
martian56 merged 2 commits into
mainfrom
fix-plugin-index-parse-errors
Jul 8, 2026
Merged

Surface malformed plugin index errors#197
martian56 merged 2 commits into
mainfrom
fix-plugin-index-parse-errors

Conversation

@martian56

@martian56 martian56 commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Fixes #178.

Summary:

  • Return parse errors from the marketplace index parser instead of treating invalid JSON as an empty index.
  • Surface malformed index errors in /plugins browse.
  • Surface malformed index errors in /plugins add <name> separately from missing plugin names.
  • Keep valid empty indexes as no plugins found and add pure parser and lookup tests.

Checks:

  • rvpm test
  • rvpm build
  • rvpm fmt --check

Summary by CodeRabbit

  • Bug Fixes

    • Malformed plugin marketplace index data is now shown as an error instead of appearing as an empty list.
    • Plugin name lookups now surface parsing issues directly, helping users understand why a plugin can’t be resolved.
  • Chores

    • Updated the app version to 0.3.17.
    • Added a changelog entry for this release.

@martian56 martian56 added bug Something isn't working plugins Plugin system ux User experience labels Jul 8, 2026
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@martian56, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 53 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4af89f85-35c1-4680-bae5-df2e425d085f

📥 Commits

Reviewing files that changed from the base of the PR and between c22f17d and 5fbbdee.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/plugins/market.rv
  • src/plugins/market_test.rv
📝 Walkthrough

Walkthrough

Introduces structured error handling for malformed plugin marketplace index JSON. Adds MarketIndex and MarketLookup result types, parse_index_result, resolve_name_result, and resolve_name_in_index functions that surface parse errors instead of treating them as empty results. Updates the /plugins add command, adds tests, and bumps version.

Changes

Marketplace index parse error surfacing

Layer / File(s) Summary
Result structs and parse error helper
src/plugins/market.rv
Adds MarketIndex { entries, error } and MarketLookup { url, error } structs, plus _index_error(detail) to format consistent parse-error messages including the market URL.
Structured index parsing
src/plugins/market.rv
Replaces parsing logic with parse_index_result, which returns entries and a structured error for malformed/non-array JSON; parse_index becomes a compatibility wrapper delegating to it.
Browse and name resolution
src/plugins/market.rv
browse_text now short-circuits with an index error via _index_error on parse failure; resolve_name is refactored into resolve_name_result/resolve_name_in_index, which return a MarketLookup populated with error on parse failure.
/plugins add error handling
src/plugins/manage.rv
Imports and uses resolve_name_result; checks resolved.error and returns it directly when present instead of silently falling through.
Tests and release notes
src/plugins/market_test.rv, CHANGELOG.md, rv.toml
Adds tests for parse_index_result and resolve_name_in_index covering bad JSON and valid empty arrays; adds a 0.3.17 changelog entry and bumps the package version.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ManageCmd as "/plugins add"
    participant Market as market.rv
    participant Index as "Marketplace Index"

    User->>ManageCmd: /plugins add <name>
    ManageCmd->>Market: resolve_name_result(name)
    Market->>Index: fetch index text
    Index-->>Market: raw response body
    Market->>Market: parse_index_result(text)
    alt JSON malformed
        Market-->>ManageCmd: MarketLookup{url:"", error:"could not parse index"}
        ManageCmd-->>User: return error message
    else JSON valid
        Market-->>ManageCmd: MarketLookup{url, error:""}
        ManageCmd-->>User: proceed with url
    end
Loading

Suggested reviewers: nazarli-shabnam

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: surfacing malformed plugin index errors.
Linked Issues check ✅ Passed The changes satisfy #178 by surfacing parse failures, preserving empty indexes, and adding coverage for bad JSON and empty arrays.
Out of Scope Changes check ✅ Passed The PR stays focused on plugin index error handling, with only the version bump and changelog update as supporting release changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-plugin-index-parse-errors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/plugins/market.rv (1)

76-88: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

HTTP errors are silently swallowed in resolve_name_result.

Both the status_code >= 400 branch (line 81) and the Err(e) branch (line 86) return MarketLookup { url: "", error: "" }, causing the caller in manage.rv to report "no plugin '${first}' in the index" — misleading when the index was unreachable. browse_text surfaces HTTP errors (line 64), so this is an inconsistency. Consider populating error for these cases as well, or at minimum for network failures.

♻️ Suggested improvement
 fun resolve_name_result(name: String) -> MarketLookup {
     let headers = "User-Agent: rook/1.0\nAccept: application/json"
     return match request_with_timeout("GET", market_url(), "", headers, TIMEOUT_MS) {
         Ok(resp) -> {
             if resp.status_code >= 400 {
-                MarketLookup { url: "", error: "" }
+                MarketLookup { url: "", error: "error: the plugin index returned ${resp.status_code}" }
             } else {
                 resolve_name_in_index(resp.body, name)
             }
         },
-        Err(e) -> MarketLookup { url: "", error: "" },
+        Err(e) -> MarketLookup { url: "", error: "error: could not reach the plugin index (${market_url()}): ${e.message}" },
     }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/plugins/market.rv` around lines 76 - 88, resolve_name_result is
swallowing HTTP and network failures by returning an empty MarketLookup in both
the non-2xx and Err paths. Update resolve_name_result to populate the error
field with the response status/message or the request failure details instead of
leaving it blank, so callers like manage.rv can distinguish “not found” from
“index unreachable”; keep the same handling consistent with browse_text and use
request_with_timeout/resolve_name_in_index/MarketLookup as the main touchpoints.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/plugins/market.rv`:
- Around line 76-88: resolve_name_result is swallowing HTTP and network failures
by returning an empty MarketLookup in both the non-2xx and Err paths. Update
resolve_name_result to populate the error field with the response status/message
or the request failure details instead of leaving it blank, so callers like
manage.rv can distinguish “not found” from “index unreachable”; keep the same
handling consistent with browse_text and use
request_with_timeout/resolve_name_in_index/MarketLookup as the main touchpoints.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3e2a52ac-bd00-406a-8a30-fcdc4a54be33

📥 Commits

Reviewing files that changed from the base of the PR and between 68b2393 and c22f17d.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • rv.toml
  • src/plugins/manage.rv
  • src/plugins/market.rv
  • src/plugins/market_test.rv

@martian56 martian56 merged commit b704294 into main Jul 8, 2026
4 checks passed
@martian56 martian56 deleted the fix-plugin-index-parse-errors branch July 8, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working plugins Plugin system ux User experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Surface malformed plugin index errors

1 participant