fix(rcc): guard against None stdout/stderr in plugin validate hook#21
Open
KerryHuang wants to merge 1 commit into
Open
fix(rcc): guard against None stdout/stderr in plugin validate hook#21KerryHuang wants to merge 1 commit into
KerryHuang wants to merge 1 commit into
Conversation
On Windows, `subprocess.run(["claude", "plugin", "validate", ...])` can
return a CompletedProcess where stdout/stderr are None instead of empty
strings (observed when the claude CLI is invoked via npm/cmd shim and
exits with no captured output before text-mode decoding completes).
The concatenation `result.stdout + result.stderr` then raises
`TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'`,
which the outer try/except surfaces as a warning to the user:
⚠ validate-frontmatter [<path>]:
- plugin validate failed: unsupported operand type(s) for +:
'NoneType' and 'str'
Coerce both streams to "" before concatenation so the hook stays silent
when claude CLI produces no output. No behavior change when both are
strings.
|
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a Windows-specific failure in the validate-frontmatter PostToolUse hook where claude plugin validate can yield CompletedProcess.stdout/stderr as None, causing a TypeError during output concatenation and producing a misleading warning despite a successful validation run.
Changes:
- Coerce
stdout/stderrto empty strings before concatenation to avoidNoneTypestring operations.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+63
to
65
| output = ((result.stdout or "") + (result.stderr or "")).strip() | ||
| if result.returncode != 0 and output: | ||
| return [f"plugin validate: {line}" for line in output.splitlines() if line.strip()] |
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.
Summary
On Windows, the
validate-frontmatterPostToolUse hook surfaces a confusing warning whenever a.claude-plugin/plugin.jsonormarketplace.jsonis edited:Root cause is in
plugins/rcc/hooks/validate_frontmatter.pyline 63:subprocess.run([\"claude\", \"plugin\", \"validate\", ...], capture_output=True, text=True)can returnCompletedProcesswithstdout=None/stderr=Noneon Windows whenclaudeis launched via the npmcmdshim and exits before text-mode decoding completes. TheNone + strconcatenation then raisesTypeError, which the outerexcept Exception as e: return [f\"plugin validate failed: {e}\"](lines 68–69) surfaces to the user.The actual
claude plugin validateinvocation succeeds (exit 0) — it's the post-processing in the hook that breaks.Fix
One-line defensive change: coerce
Noneto\"\"before concatenation.Behavior is unchanged when both streams are strings (the common case on Linux/macOS).
Reproduction (Windows 11, Claude Code CLI via npm)
plugin.jsonversionfieldclaude plugin validateitself returns 0After the fix, the hook stays silent when claude CLI produces no parseable output.
Test plan
plugin.jsonunder a clean plugin → no warningplugin.jsonthat genuinely fails validation → warning still surfaces with real diagnostics🤖 Generated with Claude Code