Skip to content

Permissions failing despite correct config #610

Closed

Description

@scottgigante-hubflow

I'm getting a permissions error despite copying the permissions from your docs. What am I doing wrong here? Is my submodules config the problem?

Error:

Run py-cov-action/python-coverage-comment-action@91aaf3b39c7e2331c6bc77767ce017f5160c5f11
/usr/bin/docker run --name e9b9989b1b58f92314aa2b10871d5f9f8aad6_64220e --label 4e9b99 --workdir /github/workspace --rm -e "database_url" -e "tms_adapter_base_url" -e "clerk_app_secret_key" -e "allowed_origins" -e "openai_api_key" -e "google_api_key" -e "debug" -e "slack_users" -e "slack_webhook_url" -e "allowed_hosts" -e "bypass_auth_creds" -e "browserbase_api_key" -e "hyperbrowser_api_key" -e "browserbase_project_id" -e "api_key_signing_key" -e "hubflow_api_url" -e "screenshots_bucket_name" -e "pythonLocation" -e "PKG_CONFIG_PATH" -e "Python_ROOT_DIR" -e "Python2_ROOT_DIR" -e "Python3_ROOT_DIR" -e "LD_LIBRARY_PATH" -e "PGSERVICEFILE" -e "INPUT_GITHUB_TOKEN" -e "INPUT_GITHUB_BASE_URL" -e "INPUT_GITHUB_PR_RUN_ID" -e "INPUT_COMMENT_TEMPLATE" -e "INPUT_COVERAGE_DATA_BRANCH" -e "INPUT_COVERAGE_PATH" -e "INPUT_COMMENT_ARTIFACT_NAME" -e "INPUT_COMMENT_FILENAME" -e "INPUT_SUBPROJECT_ID" -e "INPUT_MINIMUM_GREEN" -e "INPUT_MINIMUM_ORANGE" -e "INPUT_MAX_FILES_IN_COMMENT" -e "INPUT_MERGE_COVERAGE_FILES" -e "INPUT_ANNOTATE_MISSING_LINES" -e "INPUT_ANNOTATION_TYPE" -e "INPUT_USE_GH_PAGES_HTML_URL" -e "INPUT_VERBOSE" -e "GITHUB_BASE_URL" -e "GITHUB_TOKEN" -e "GITHUB_PR_RUN_ID" -e "COMMENT_TEMPLATE" -e "COVERAGE_DATA_BRANCH" -e "COVERAGE_PATH" -e "COMMENT_ARTIFACT_NAME" -e "COMMENT_FILENAME" -e "SUBPROJECT_ID" -e "MINIMUM_GREEN" -e "MINIMUM_ORANGE" -e "MERGE_COVERAGE_FILES" -e "ANNOTATE_MISSING_LINES" -e "ANNOTATION_TYPE" -e "VERBOSE" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/hubflow-api/hubflow-api":"/github/workspace" 4e9b99:89b1b58f92314aa2b10871d5f9f8aad6
Notice: Starting action
Notice: HTTP Request: GET https://api.github.com/repos/hubflowai/hubflow-api "HTTP/1.1 200 OK"
Notice: Computing coverage files & badge
Notice: HTTP Request: GET https://img.shields.io/static/v1?label=Coverage&message=78%25&color=orange "HTTP/1.1 200 OK"
Notice: Saving coverage files
Error: Critical error. This error possibly occurred because the permissions of the workflow are set incorrectly. You can see the correct setting of permissions here: https://github.com/py-cov-action/python-coverage-comment-action#basic-usage
Otherwise please look for open issues or open one in https://github.com/py-cov-action/python-coverage-comment-action/
Traceback (most recent call last):
  File "/workdir/coverage_comment/subprocess.py", line 22, in run
    return subprocess.run(
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('git', 'push', 'origin', 'python-coverage-comment-action-data')' returned non-zero exit status 128.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/workdir/coverage_comment/subprocess.py", line 65, in _git
    return run(
           ^^^^
  File "/workdir/coverage_comment/subprocess.py", line 36, in run
    raise SubProcessError("\n".join([exc.stderr, exc.stdout])) from exc
coverage_comment.subprocess.SubProcessError: remote: Write access to repository not granted.
fatal: unable to access 'https://github.com/hubflowai/hubflow-api/': The requested URL returned error: 403

Config:

  test:
    runs-on: ubuntu-latest
    permissions:
      # Gives the action the necessary permissions for publishing new
      # comments in pull requests.
      pull-requests: write
      # Gives the action the necessary permissions for pushing data to the
      # python-coverage-comment-action branch, and for editing existing
      # comments (to avoid publishing multiple comments in the same PR)
      contents: write
    steps:
      - name: Checkout code
        uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
        with:
          token: ${{ secrets.PULL_TOKEN }}
          submodules: true

      [...]

      - name: Run pytest
        run: pytest -n 2 -v --exitfirst

      - name: Coverage comment
        uses: py-cov-action/python-coverage-comment-action@91aaf3b39c7e2331c6bc77767ce017f5160c5f11 # v3
        with:
          GITHUB_TOKEN: ${{ github.token }}

Activity

  1. ewjoachim commented on Oct 3, 2025

    @ewjoachim
    Member

    Could it be that your repo would have restrictive settings in Actions settings in the repo settings ?

    A screenshot for reference

    Image
  2. scottgigante-hubflow commented on Oct 3, 2025

    @scottgigante-hubflow
    Author

    It was on read-only, though by my eye this only reflects the default permissions which could be changed by the permissions section.

    I updated this to read-write and still getting the same error

  3. scottgigante-hubflow commented on Oct 3, 2025

    @scottgigante-hubflow
    Author

    Update: I gave contents: write permissions to secrets.PULL_TOKEN and now it works. It looks like the action is using the token the repo was cloned with, rather than the token provided to it in with: GITHUB_TOKEN:

  4. ewjoachim commented on Oct 5, 2025

    @ewjoachim
    Member

    Oh! Thanks for the investigation! Would you be interested in providing a fix ?

  5. tim-schilling commented on Nov 14, 2025

    @tim-schilling
    Contributor

    I have ran into this same error, but it was due to having persist-credentials: false on the action. This tends to be a recommendation from Zizmor and I may have gotten a bit overzealous with it. @ewjoachim what do you think about changing the examples to explicitly set persist-credentials: true? It should be unnecessary because that's the default, but it seems like "proper" security would be for GitHub to default that to false.

  6. ewjoachim commented on Nov 17, 2025

    @ewjoachim
    Member

    Great idea :) Want to contribute ?
    Alternatively, it could make sense to document (or fix) how to make this work with persist-credentials: false. I believe that if we're explicitly given a token, we should be able to make use of it.

  7. tim-schilling commented on Nov 18, 2025

    @tim-schilling
    Contributor

    I will draft up a docs PR. I tried doing a bit of looking. If you can figure out how to set the PAT for all the Git.[method] calls, it should work. I'm not quite sure how that will be managed. I'm guessing maybe something in the set up flow to make sure the local git instance is setup with a token?

  8. nigelmegitt commented on Jun 12, 2026

    @nigelmegitt

    I'm also getting an error that's most likely a permissions error, which was introduced between 2026-05-21 (last time my workflow ran successfully) and 2026-06-05, during which time I didn't change any permissions on the repo.

    The first time it failed was a Dependabot PR that updated actions/checkout from v6 to v6.0.2, which wasn't merged. Earlier Dependabot PRs had successful workflow runs, with the same workflow file.

    The second time it failed was another Dependabot PR that updated astral-sh/setup-uv from 8.1.0 to 8.2.0. The actual checkout worked fine: the only thing that failed was the python-coverage-comment-action so I merged the PR just in case it was some artifact of the permissions associated with the PR. That triggered a workflow run from the default branch, which also failed with the same error.

    The log result on the failing run, after successfully generating .coverage is un

    Open to reveal log result

    Run py-cov-action/[email protected]
      with:
        GITHUB_TOKEN: ***
        GITHUB_BASE_URL: https://api.github.com/
        COVERAGE_DATA_BRANCH: python-coverage-comment-action-data
        COVERAGE_PATH: .
        COMMENT_ARTIFACT_NAME: python-coverage-comment-action
        COMMENT_FILENAME: python-coverage-comment-action.txt
        MINIMUM_GREEN: 100
        MINIMUM_ORANGE: 70
        MAX_FILES_IN_COMMENT: 25
        MERGE_COVERAGE_FILES: false
        ANNOTATE_MISSING_LINES: false
        ANNOTATION_TYPE: warning
        USE_GH_PAGES_HTML_URL: false
        VERBOSE: false
      env:
        pythonLocation: /opt/hostedtoolcache/Python/3.14.5/x64
        PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.14.5/x64/lib/pkgconfig
        Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.14.5/x64
        Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.14.5/x64
        Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.14.5/x64
        LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.14.5/x64/lib
        UV_PYTHON_INSTALL_DIR: /home/runner/work/_temp/uv-python-dir
        UV_CACHE_DIR: /home/runner/work/_temp/setup-uv-cache
    /usr/bin/docker run --name e8d0ed34b744b48d784c6d00dee531_68a6cc --label 463353 --workdir /github/workspace --rm -e "pythonLocation" -e "PKG_CONFIG_PATH" -e "Python_ROOT_DIR" -e "Python2_ROOT_DIR" -e "Python3_ROOT_DIR" -e "LD_LIBRARY_PATH" -e "UV_PYTHON_INSTALL_DIR" -e "UV_CACHE_DIR" -e "INPUT_GITHUB_TOKEN" -e "INPUT_GITHUB_BASE_URL" -e "INPUT_GITHUB_PR_RUN_ID" -e "INPUT_COMMENT_TEMPLATE" -e "INPUT_COVERAGE_DATA_BRANCH" -e "INPUT_COVERAGE_PATH" -e "INPUT_COMMENT_ARTIFACT_NAME" -e "INPUT_COMMENT_FILENAME" -e "INPUT_SUBPROJECT_ID" -e "INPUT_MINIMUM_GREEN" -e "INPUT_MINIMUM_ORANGE" -e "INPUT_MAX_FILES_IN_COMMENT" -e "INPUT_MERGE_COVERAGE_FILES" -e "INPUT_ANNOTATE_MISSING_LINES" -e "INPUT_ANNOTATION_TYPE" -e "INPUT_USE_GH_PAGES_HTML_URL" -e "INPUT_VERBOSE" -e "GITHUB_BASE_URL" -e "GITHUB_TOKEN" -e "GITHUB_PR_RUN_ID" -e "COMMENT_TEMPLATE" -e "COVERAGE_DATA_BRANCH" -e "COVERAGE_PATH" -e "COMMENT_ARTIFACT_NAME" -e "COMMENT_FILENAME" -e "SUBPROJECT_ID" -e "MINIMUM_GREEN" -e "MINIMUM_ORANGE" -e "MERGE_COVER
    Notice: Starting action
    Notice: HTTP Request: GET https://api.github.com/repos/bbc/ttml-validator "HTTP/1.1 200 OK"
    Notice: Computing coverage files & badge
    Error: Critical error. This error possibly occurred because the permissions of the workflow are set incorrectly. You can see the correct setting of permissions here: https://github.com/py-cov-action/python-coverage-comment-action#basic-usage
    Otherwise please look for open issues or open one in https://github.com/py-cov-action/python-coverage-comment-action/
    Traceback (most recent call last):
      File "/workdir/coverage_comment/main.py", line 46, in main
        exit_code = action(
            config=config,
        ...<2 lines>...
            git=git,
        )
      File "/workdir/coverage_comment/main.py", line 93, in action
        return save_coverage_data_files(
            config=config,
        ...<2 lines>...
            repo_info=repo_info,
        )
      File "/workdir/coverage_comment/main.py", line 402, in save_coverage_data_files
        raw_coverage_data, coverage = coverage_module.get_coverage_info(
                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
            merge=config.MERGE_COVERAGE_FILES,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            coverage_path=config.COVERAGE_PATH,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "/workdir/coverage_comment/coverage.py", line 120, in get_coverage_info
        json_coverage = json.loads(
            subprocess.run("coverage", "json", "-o", "-", path=coverage_path)
        )
      File "/usr/local/lib/python3.14/json/__init__.py", line 352, in loads
        return _default_decoder.decode(s)
               ~~~~~~~~~~~~~~~~~~~~~~~^^^
      File "/usr/local/lib/python3.14/json/decoder.py", line 345, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
                   ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.14/json/decoder.py", line 363, in raw_decode
        raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    
    

    It looks like it's trying to decode a JSON file that possibly doesn't exist, or is empty, which is odd, and that this failure is being caught and reported as a possible permissions error.

    My CI file: https://github.com/bbc/ttml-validator/blob/main/.github/workflows/ci.yml

    I tried adding persist-credentials: true and it made no difference.

    Any help much appreciated, I'm baffled!

  9. ewjoachim commented on Jun 18, 2026

    @ewjoachim
    Member

    It looks like it's trying to decode a JSON file that possibly doesn't exist, or is empty, which is odd, and that this failure is being caught and reported as a possible permissions error.

    It's likely trying to run coverage json -o - which likely outputs an error in stderr and nothing in stdout. And it looks like we're missing a check on the exit code of this subprocess :( EDIT: no, it's something else.

    Can you open a dedicated issue please ?
    Also, can you run with debug as explained in https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging ?
    When you click on rerun failed job, there's a checkbox

    Image

    EDIT: i've gone ahead and opened #676

  10. ewjoachim commented on Jun 21, 2026

    @ewjoachim
    Member

    @tim-schilling persist-credentials is now the default following #698

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions