fix(issue-comment): improve 403 error handling with actionable guidance#698
Conversation
- Detect 403 permission errors specifically (status code, message patterns) - Provide detailed guidance on likely causes: - GitHub Apps: issues:write permission - GITHUB_TOKEN: permissions block in workflow YAML - Fine-grained PATs: Issues repository permission - Classic PATs: repo scope - Save failed comment payload to .github/artifacts/ for manual posting - Add structured error output with JSON for programmatic consumption - Add GitHub Actions outputs for workflow integration - New exit code 5 for permission denied errors Closes #643 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughThe changes introduce 403 permission-denied error handling to the Post-IssueComment script with structured diagnostics and artifact output. A new helper function detects 403 errors, generates debug payloads, and exits with code 4 per ADR-035. Exit code documentation is updated to reflect the consolidated mapping. Changes
Sequence DiagramsequenceDiagram
actor User
participant Script as Post-IssueComment
participant API as GitHub API
participant FS as Filesystem
participant Actions as GitHub Actions
User->>Script: Call with comment body
Script->>API: POST /repos/OWNER/REPO/issues/ISSUE/comments
alt HTTP 403 Response
API-->>Script: 403 Permission Denied
rect rgb(255, 200, 200)
Note over Script: Detect 403 error pattern
Script->>FS: Resolve .github/artifacts directory
Script->>FS: Write payload JSON file
Script->>Actions: Set GITHUB_OUTPUT variables<br/>(status, error, artifact_path, success)
end
Script-->>User: Print guidance (token type, permissions)
Script->>Script: Exit code 4 (auth error)
else HTTP Other Error
API-->>Script: Non-403 error
Script->>Script: Exit code 3 (external error)
else Success
API-->>Script: 201 Created
Script->>Script: Exit code 0 (success)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
Comment |
PR Validation ReportNote ✅ Status: PASS Description Validation
QA Validation
⚡ Warnings
Powered by PR Validation workflow |
There was a problem hiding this comment.
Code Review
This pull request significantly improves error handling for 403 permission issues by providing actionable guidance and saving the comment payload, which is a valuable enhancement. My review focuses on aligning the new helper function with the repository's PowerShell style guide and improving the robustness of the artifact creation logic, incorporating relevant repository rules where applicable. I've provided specific suggestions to address these points.
Spec-to-Implementation ValidationTip ✅ Final Verdict: PASS What is Spec Validation?This validation ensures your implementation matches the specifications:
Validation Summary
Spec References
Requirements Traceability DetailsBased on my analysis of Issue #643 and the implementation changes, here is the requirements traceability assessment: Requirements Coverage Matrix
Summary
GapsNone identified. All acceptance criteria from Issue #643 are addressed:
VERDICT: PASS Implementation Completeness DetailsAcceptance Criteria ChecklistBased on Issue #643, the acceptance criteria is:
Missing FunctionalityNone identified. All requirements from Issue #643 are implemented. Edge Cases Not Covered
Implementation Quality
VERDICT: PASS Run Details
Powered by AI Spec Validator workflow |
AI Quality Gate ReviewWarning WalkthroughThis PR was reviewed by six AI agents in parallel, analyzing different aspects of the changes:
Review Summary
💡 Quick Access: Click on individual agent jobs (e.g., "🔒 security Review", "🧪 qa Review") in the workflow run to see detailed findings and step summaries. QA Review DetailsI cannot run PowerShell tests due to environment restrictions. I'll complete the QA review based on static analysis. Test Coverage Assessment
Fail-Safe Pattern Verification
Quality Concerns
Regression Risk Assessment
Architect Review DetailsNow I have the full context. Let me provide my architecture review. Design Quality Assessment
Overall Design Score: 3.8/5 Architectural Concerns
Breaking Change Assessment
The change from exit code 3 to 4 for 403 errors is a semantic correction, not a breaking change. ADR-035 specifies exit 4 for auth/authorization errors. No existing callers would rely on 403 returning exit 3 since the original behavior was undifferentiated API failure. Technical Debt Analysis
ADR Assessment
The change correctly applies ADR-035 exit code semantics:
Recommendations
VerdictRoadmap Review DetailsStrategic Alignment Assessment
Feature Completeness
Impact Analysis
Concerns
Recommendations
VerdictAnalyst Review DetailsNow let me check if there's an ADR-035 referenced and look at the related issue for context. Now I have complete context. Let me analyze this PR. PR Analysis: Post-IssueComment 403 Error HandlingCode Quality Score
Overall: 4/5 Impact Assessment
Findings
Recommendations
Positive Observations
VerdictDevOps Review DetailsBased on my analysis, this PR modifies a PowerShell script and its tests. No workflow files, actions, or scripts in Pipeline Impact Assessment
CI/CD Quality Checks
Findings
Template Assessment
Automation Opportunities
Recommendations
VerdictSecurity Review DetailsSecurity Review: PR #643 - 403 Error HandlingPR Type: CODE (PowerShell scripts)Full OWASP review required. Findings
AnalysisPositive Security Patterns:
403 Detection Logic Review (Line 300): $errorString -imatch 'HTTP 403' -or $errorString -imatch 'status.*403' -or $errorString -match '403' -or $errorString -imatch 'Resource not accessible by integration' -or $errorString -imatch '\bforbidden\b'The pattern is intentionally broad to catch various GitHub API error formats. The Exit Code Change:
This aligns with the documented exit code standard in GitHubCore.psm1. Test File Relocation: Recommendations
VerdictRun Details
Powered by AI Quality Gate workflow |
- Add [CmdletBinding()] to Write-PermissionDeniedError function - Use Write-Error instead of Write-Host for error output - Use git rev-parse --show-toplevel for artifact directory - Add 8 Pester tests for 403 error handling Addresses review comments on #698. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Review Triage RequiredNote Priority: NORMAL - Human approval required before bot responds Review Summary
Next Steps
Powered by PR Maintenance workflow - Add triage:approved label |
Addresses review findings from PR #698: ## Critical Fixes - Add try-catch with -ErrorAction Stop around New-Item for artifact directory - Add try-catch with -ErrorAction Stop around Set-Content for artifact file - Add fallback to console output when file operations fail ## Important Fixes - Add [Parameter(Mandatory)] and [ValidateNotNullOrEmpty()] attributes - Fix exit code 5 documentation conflict in GitHubCore.psm1 - Add logging when git rev-parse fallback occurs - Use case-insensitive matching (-imatch) for 403 detection patterns - Clarify GitHub App manifest format ("issues": "write" JSON syntax) - Add behavioral tests for 403 detection logic ## Documentation Improvements - Clarify Classic PAT guidance (public_repo for public repos) - Update exit code 5 documentation (Permission denied, not Idempotency skip) ## Test Additions - Add 5 new structural tests for improved error handling - Add 9 behavioral tests for 403 pattern matching with various error formats 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Addresses PR #698 review feedback: ## Exit Code Alignment (Option A per reviewer) - Changed 403 permission denied from exit code 5 to exit code 4 - Exit code 4 now covers all auth errors (not-authenticated AND permission-denied) - Updated GitHubCore.psm1 exit code documentation to match ADR-035 - Updated tests to expect exit code 4 ## Test Location (per reviewer) - Moved Post-IssueComment.Tests.ps1 from .claude/skills/github/tests/ to repository root tests/ folder - CI concern, not skill concern - Updated script path references in test file All 73 tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 403-specific error handling to Update-IssueComment in GitHubCore.psm1: - Detect 403 errors using same pattern as Post-IssueComment.ps1 - Provide actionable guidance for permission issues - Include update-specific cause: "Not the comment author" - Use exit code 4 per ADR-035 (auth/permission errors) - Fall back to exit code 3 for generic API errors This matches the 403 handling pattern established in PR #698. Closes #701 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…#712) Add 403-specific error handling to Update-IssueComment in GitHubCore.psm1: - Detect 403 errors using same pattern as Post-IssueComment.ps1 - Provide actionable guidance for permission issues - Include update-specific cause: "Not the comment author" - Use exit code 4 per ADR-035 (auth/permission errors) - Fall back to exit code 3 for generic API errors This matches the 403 handling pattern established in PR #698. Closes #701 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: rjmurillo[bot] <rjmurillo-bot@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Pull Request
Summary
Improves Post-IssueComment.ps1 error handling to detect 403 permission errors specifically and provide actionable guidance for resolution. When 403 occurs, saves the comment payload to an artifact file for manual posting.
Specification References
Changes
Write-PermissionDeniedErrorhelper function with detailed guidanceissues:writepermission in app manifestpermissions: issues: writein YAMLreposcope.github/artifacts/failed-comment-{timestamp}.jsonsuccess,error,status_code,artifact_path)Type of Change
Testing
Agent Review
Security Review
Other Agent Reviews
Checklist
🤖 Generated with Claude Code