Skip to content

fix(review-pr): parse args from JSON string in workflow script - #53

Merged
cblecker merged 1 commit into
mainfrom
worktree-fix-parcing
Jun 22, 2026
Merged

fix(review-pr): parse args from JSON string in workflow script#53
cblecker merged 1 commit into
mainfrom
worktree-fix-parcing

Conversation

@cblecker

@cblecker cblecker commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • The Workflow runtime delivers args as a JSON string, not a parsed object. This caused config.owner, config.repo, etc. to all be undefined, producing literal "undefined" strings in downstream agent prompts.
  • Defensively parse args from JSON when it arrives as a string, falling back to the raw value or {}.
  • Bump plugin version 1.4.01.4.1 (patch).

Test plan

  • Invoke the review-pr workflow with a JSON args object and confirm config.* properties resolve correctly
  • Run claude plugin validate ./pr-review-toolkit — should pass

Summary by CodeRabbit

  • Chores

    • Updated plugin version to 1.4.1
  • Improvements

    • Enhanced configuration initialization to support more flexible input handling

Copilot AI review requested due to automatic review settings June 22, 2026 16:10
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@cblecker, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 39 minutes and 55 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

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

🚦 How do rate limits work?

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

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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b41ece02-6ff6-4ae1-b3b1-d955daf3734d

📥 Commits

Reviewing files that changed from the base of the PR and between 684787c and 12475e8.

📒 Files selected for processing (2)
  • pr-review-toolkit/.claude-plugin/plugin.json
  • pr-review-toolkit/skills/review-pr/review-pr.js
📝 Walkthrough

Walkthrough

In review-pr.js, the config initialization is updated to conditionally parse args with JSON.parse when args is a string, falling back to args || {} otherwise. The plugin manifest version is bumped from 1.4.0 to 1.4.1.

Changes

Args Parsing and Version Bump

Layer / File(s) Summary
JSON args parsing and manifest version bump
pr-review-toolkit/skills/review-pr/review-pr.js, pr-review-toolkit/.claude-plugin/plugin.json
config initialization now uses JSON.parse(args) when args is a string, otherwise falls back to args || {}; plugin manifest version bumped to 1.4.1.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • cblecker/claude-plugins#45: Introduced the initial review-pr.js implementation with workflow orchestration and argument handling that this PR's parsing change builds upon.
  • cblecker/claude-plugins#49: Also modifies the config/setup path in review-pr.js, changing how workflow inputs and config fields drive downstream logic.

Poem

🐇 A string of JSON came hopping by,
Unparsed and raw beneath the sky.
I added a check — just one small line —
Now config reads the args just fine!
The version ticked, the plugin's new,
🥕 Another fix from me to you!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing JSON string parsing of args in the review-pr workflow script, which is the core objective of this patch.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-fix-parcing

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 and usage tips.

Copilot AI 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.

Pull request overview

This PR fixes a runtime bug in the pr-review-toolkit plugin's review-pr workflow script. The Workflow runtime delivers the args payload as a JSON string rather than a parsed object, which caused config.owner, config.repo, and other properties to resolve to undefined, leaking literal "undefined" strings into the agent prompts. The fix parses args when it arrives as a string while preserving the existing object/fallback behavior, and bumps the plugin's patch version.

Changes:

  • Parse args via JSON.parse when it is a string, otherwise fall back to args || {}.
  • Bump pr-review-toolkit plugin version 1.4.01.4.1.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pr-review-toolkit/skills/review-pr/review-pr.js Defensively parses args from a JSON string so config.* properties resolve correctly.
pr-review-toolkit/.claude-plugin/plugin.json Patch version bump reflecting the fix.

I verified the version bump is self-consistent: marketplace.json does not pin a version for pr-review-toolkit, so no other reference requires updating (the 1.4.0 in git/.claude-plugin/plugin.json belongs to the unrelated git plugin). The parsing change correctly handles both the string and object input cases, and the repository has no unit tests (CI only runs skillsaw, markdownlint, and claude plugin validate), so no test-coverage gap applies.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Actionable comments posted: 1

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

Inline comments:
In `@pr-review-toolkit/skills/review-pr/review-pr.js`:
- Line 131: The JSON.parse call in the config constant assignment lacks error
handling, which causes the workflow to abort when args contains malformed JSON.
Wrap the JSON.parse(args) operation in a try-catch block to gracefully handle
parsing errors, falling back to an empty object or default configuration when
the JSON parsing fails instead of propagating the exception.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b423e7e4-daef-4370-ba3d-411d51213a9a

📥 Commits

Reviewing files that changed from the base of the PR and between b02a2eb and 684787c.

📒 Files selected for processing (2)
  • pr-review-toolkit/.claude-plugin/plugin.json
  • pr-review-toolkit/skills/review-pr/review-pr.js

}

const config = args || {}
const config = typeof args === 'string' ? JSON.parse(args) : (args || {})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard JSON.parse to prevent workflow abort on malformed string args (Line 131).

JSON.parse(args) is unhandled here; malformed JSON will throw and terminate the workflow instead of falling back, which reintroduces brittle behavior in this path.

Proposed fix
-const config = typeof args === 'string' ? JSON.parse(args) : (args || {})
+const config = (() => {
+  if (typeof args !== "string") return args || {}
+  try {
+    const parsed = JSON.parse(args)
+    return parsed || {}
+  } catch {
+    return {}
+  }
+})()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const config = typeof args === 'string' ? JSON.parse(args) : (args || {})
const config = (() => {
if (typeof args !== "string") return args || {}
try {
const parsed = JSON.parse(args)
return parsed || {}
} catch {
return {}
}
})()
🤖 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 `@pr-review-toolkit/skills/review-pr/review-pr.js` at line 131, The JSON.parse
call in the config constant assignment lacks error handling, which causes the
workflow to abort when args contains malformed JSON. Wrap the JSON.parse(args)
operation in a try-catch block to gracefully handle parsing errors, falling back
to an empty object or default configuration when the JSON parsing fails instead
of propagating the exception.

The Workflow runtime delivers args as a JSON string, not a parsed
object, causing config properties to be undefined.

Assisted-by: Claude:claude-opus-4-6
@cblecker
cblecker force-pushed the worktree-fix-parcing branch from 684787c to 12475e8 Compare June 22, 2026 16:30
@cblecker
cblecker merged commit 41c517d into main Jun 22, 2026
11 checks passed
@cblecker
cblecker deleted the worktree-fix-parcing branch June 22, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants