Skip to content

fix(issue-comment): add ConvertFrom-Json error handling #700

@rjmurillo-bot

Description

@rjmurillo-bot

Summary

The Post-IssueComment.ps1 script has unprotected ConvertFrom-Json calls that could fail silently with malformed API responses.

Problem

Lines 85 and 269 contain ConvertFrom-Json without error handling:

# Line 85 - parsing comments list
$comments = $commentsJson | ConvertFrom-Json

# Line 269 - parsing response after post
$response = $result | ConvertFrom-Json

If the GitHub API returns invalid JSON (rate limiting HTML page, network truncation, API error response), these calls will fail with an unhelpful error.

Solution

Wrap in try-catch with descriptive error handling:

try {
    $comments = $commentsJson | ConvertFrom-Json -ErrorAction Stop
}
catch {
    Write-ErrorAndExit "Failed to parse GitHub API response: $($_.Exception.Message). Raw response: $($commentsJson.Substring(0, [Math]::Min(200, $commentsJson.Length)))" 3
}

Severity

LOW - API responses are typically well-formed, but edge cases exist:

  • Rate limiting returns HTML
  • Network issues can truncate responses
  • API changes could alter response format

Affected Files

  • .claude/skills/github/scripts/issue/Post-IssueComment.ps1

Related


🤖 Generated with Claude Code

Metadata

Metadata

Assignees

Labels

area-promptsAgent prompts and templatesarea-skillsSkills documentation and patternsbugSomething isn't workinggood first issueGood for newcomerspriority:P2Normal: Standard enhancement or bug fix, moderate impact

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions