Skip to content

Commit dda025d

Browse files
MishaKavclaude
andauthored
Fix issue #68: Improve error handling and documentation for permission errors (#231)
* Fix issue #68: Add better error handling and documentation for permission errors This commit addresses the "Resource not accessible by integration" error that users encounter when the GITHUB_TOKEN lacks necessary permissions. Changes: - Add comprehensive error handling in src/index.js that catches 403 permission errors and provides actionable guidance with correct permissions block - Update README.md permissions examples to show minimal required permissions (contents: read, pull-requests: write) instead of excessive permissions - Expand troubleshooting section with detailed explanation of permission errors, common error messages, and why the issue appears differently on forks - Update action.yml description to mention required permissions upfront - Add permission requirement note to github-token input description The action now provides clear, helpful error messages when permission issues occur, directing users to add the correct permissions block to their workflow. Fixes #68 * Update CHANGELOG and bump version to 1.1.59 * Add Node version file and update package-lock - Add .nvmrc to specify Node v20.12.2 - Update package-lock.json to lockfileVersion 3 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Address PR review comments - Update Node.js to v20.19.5 (fixes CVE-2024-27980) - Improve error handling with null safety and consistent error reporting - Update error message for better clarity - Add lockfile upgrade explanation to CHANGELOG 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Remove internal Node.js version update from CHANGELOG 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Upgrade ESLint from 8.57.1 to 9.39.1 - Update to ESLint 9 with flat config system - Add @eslint/js and globals packages - Create eslint.config.js with flat config format - Remove deprecated eslintConfig from package.json - All tests passing with no linting errors 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Remove peer dependencies from package-lock.json for several packages to streamline dependency management. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4adeec5 commit dda025d

10 files changed

Lines changed: 34983 additions & 15397 deletions

File tree

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v20.19.5

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog of the Pytest Coverage Comment
22

3+
## [Pytest Coverage Comment 1.1.59](https://github.com/MishaKav/pytest-coverage-comment/tree/v1.1.59)
4+
5+
**Release Date:** 2025-11-08
6+
7+
#### Changes
8+
9+
- fix "Resource not accessible by integration" error with better error handling and documentation (#68)
10+
- update permission examples to show minimal required permissions (contents: read, pull-requests: write)
11+
- upgrade package-lock.json from lockfileVersion 2 to 3 (causes extensive but cosmetic changes in dist/index.js)
12+
313
## [Pytest Coverage Comment 1.1.58](https://github.com/MishaKav/pytest-coverage-comment/tree/v1.1.58)
414

515
**Release Date:** 2025-11-08

README.md

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ on:
107107
- '*'
108108

109109
permissions:
110-
contents: write
111-
checks: write
110+
contents: read
112111
pull-requests: write
113112

114113
jobs:
@@ -540,16 +539,40 @@ If you want auto-update the coverage badge on your README, you can see the [work
540539

541540
**Issue**: The action runs successfully but no comment appears on the PR.
542541

542+
**Root Cause**: This is usually caused by insufficient GitHub token permissions. The `GITHUB_TOKEN` needs write access to create/update PR comments.
543+
544+
**Common Error Messages**:
545+
- `Error: Resource not accessible by integration`
546+
- `HttpError: Resource not accessible by integration`
547+
- `403 Forbidden` errors in the action logs
548+
543549
**Solutions**:
544550

545-
- Ensure proper permissions are set:
546-
```yaml
547-
permissions:
548-
contents: write
549-
pull-requests: write
550-
```
551-
- For `workflow_dispatch`, provide the `issue-number` input
552-
- Check if `hide-comment` is set to `false`
551+
1. **Add permissions block to your workflow** (Recommended):
552+
```yaml
553+
permissions:
554+
contents: read # Required for checkout and comparing commits
555+
pull-requests: write # Required for creating/updating PR comments
556+
```
557+
558+
2. **For `push` events with commit comments**, use:
559+
```yaml
560+
permissions:
561+
contents: write # Required for creating commit comments
562+
pull-requests: write # If you also want PR comments
563+
```
564+
565+
3. **Repository/Organization Settings** (Admin access required):
566+
- Go to Settings > Actions > General
567+
- Under "Workflow permissions", select "Read and write permissions"
568+
- Note: This affects all workflows, so adding permissions to individual workflows is more secure
569+
570+
4. **Other checks**:
571+
- For `workflow_dispatch` events, provide the `issue-number` input
572+
- Verify `hide-comment` is not set to `true`
573+
- Check branch protection rules aren't blocking automated comments
574+
575+
**Why it works on forks but not main repos**: Forks often have different default permission settings than the main repository. Organizations frequently set restrictive defaults for security.
553576

554577
### Unrecognized Arguments Error
555578

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name: 'Pytest Coverage Comment'
2-
description: 'GitHub Action that adds pytest coverage reports as comments to pull requests with badges, test statistics, and direct file links'
2+
description: 'GitHub Action that adds pytest coverage reports as comments to pull requests with badges, test statistics, and direct file links. Requires pull-requests: write permission.'
33
author: 'Misha Kav'
44
branding:
55
icon: 'message-circle'
66
color: 'blue'
77

88
inputs:
99
github-token:
10-
description: 'GitHub token for API access to create/update comments'
10+
description: 'GitHub token for API access to create/update comments. Ensure your workflow has pull-requests: write permission.'
1111
default: ${{ github.token }}
1212
required: true
1313

0 commit comments

Comments
 (0)