> ## Content Index
> Fetch the complete content index at: https://blog.sudowl.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# My CLA Check Was Red on Every Pull Request. Here's the Fix
- URL: https://blog.sudowl.com/github-actions-cla-check-fails-personal-access-token/
- Published: 2026-11-19T10:00:00.000Z
- Updated: 2026-12-04T12:22:14.000Z
- Description: CLA Assistant action failing with "Please add a personal access token"? Store signatures in the same repo with GITHUB_TOKEN. Plus three more gotchas.
- Author: Lukas
- Tags: Security

I maintain a small open-source project that's dual-licensed (AGPL plus a commercial license). Dual licensing only works if you actually own the rights to every line, so outside contributors have to sign a Contributor License Agreement before their pull request goes in. The usual way to do that on GitHub is the CLA Assistant action: it comments on the PR, the contributor replies with a magic sentence, the bot stores the signature in a JSON file and the check turns green.

Except mine had never turned green. Not once. I only noticed when I opened a PR for something completely unrelated and every check passed except **CLA**, red after 6 seconds.

**TL;DR:** The workflow was set up to store signatures in a *separate* repository. That needs a personal access token, and the secret for it was never created, so the action died on every PR before doing anything. Fix: drop the remote-repo settings, store signatures in the same repo on a dedicated branch, and the default `GITHUB_TOKEN` is enough. Then expect the first run after the fix to fail anyway, because the action always fails on the run that creates the signature file.

## The error

The failing log, trimmed to the parts that matter:

```text
CLA Assistant GitHub Action bot has started the process
##[error]Please add a personal access token as an environment variable for writing signatures in a remote repository/organization as mentioned in the README.md file
##[error]Could not retrieve repository contents. Status: unknown

```

And further up, in the step's env dump:

```text
env:
  GITHUB_TOKEN: ***
  PERSONAL_ACCESS_TOKEN: 

```

That empty `PERSONAL_ACCESS_TOKEN` is the whole story. Getting there:

```bash
gh pr checks 1
gh run view <run-id> --log-failed | tail -15

```

`gh run view --log-failed` is the fastest way to read a failing Action without clicking through the web UI. Use it.

## The broken workflow

This is what was in `.github/workflows/cla.yml` (org and repo names swapped for examples):

```yaml
name: CLA Assistant
on:
  issue_comment:
    types: [created]
  pull_request_target:
    types: [opened, closed, synchronize]
permissions:
  actions: write
  contents: write
  pull-requests: write
  statuses: write
jobs:
  CLA:
    runs-on: ubuntu-latest
    steps:
      - name: CLA Assistant
        if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
        uses: contributor-assistant/github-action@v2.6.1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          # PERSONAL_ACCESS_TOKEN with repo scope on the signatures repo.
          PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_ASSISTANT_PAT }}
        with:
          path-to-signatures: 'signatures/v1/cla.json'
          path-to-document: 'https://github.com/example-org/my-project/blob/main/CLA.md'
          branch: 'main'
          allowlist: example-maintainer,bot*
          remote-organization-name: example-org
          remote-repository-name: my-project-cla-signatures

```

The two `remote-*` lines tell the action to write signatures into another repository. The built-in `GITHUB_TOKEN` is scoped to the repo the workflow runs in, so it can't write anywhere else. That's why the action insists on a PAT as soon as you set a remote repo. Somebody (me) copied this from a template, left a nice comment explaining that a secret has to be created, and then never created it. A reference to a missing secret doesn't error in GitHub Actions, it just expands to an empty string. So nothing complained at setup time, only at runtime.

The separate-repo setup does have a point: signature commits stay out of your project history, and you can share one signature file across several repos. For one project, it's a long-lived token with write access sitting in your secrets for no real gain. I'd rather not have that token at all.

## The fix: same repo, own branch

```yaml
        env:
          # Signatures live in this repo, so the default token is enough.
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          path-to-signatures: 'signatures/v1/cla.json'
          path-to-document: 'https://github.com/example-org/my-project/blob/main/CLA.md'
          # A dedicated branch keeps the bot's signature commits off main.
          branch: 'cla-signatures'
          allowlist: example-maintainer,bot*

```

Removed: the `PERSONAL_ACCESS_TOKEN` line, both `remote-*` lines. Changed: `branch` from `main` to `cla-signatures`. The workflow already had `contents: write` in its `permissions` block, so the default token can commit the signature file.

Why a separate branch and not `main`? Because otherwise every new contributor signature is a bot commit on `main`, and if you ever protect `main` the bot can't write there anymore. A throwaway branch nobody merges keeps both problems away.

The action expects that branch to exist, so create it before the workflow runs:

```bash
git push origin main:refs/heads/cla-signatures
git ls-remote --heads origin cla-signatures

```

Then a quick grep to make sure nothing else still points at the old signatures repo or the secret name:

```bash
grep -rn "my-project-cla-signatures\|CLA_ASSISTANT_PAT" --exclude-dir=.git --exclude-dir=node_modules .

```

Empty output, good. Commit, PR, merge.

## Gotcha: the PR that fixes the workflow can't prove the fix

The CLA check on the fix PR itself was red again. Not because the fix was wrong. `pull_request_target` runs the workflow file **from the base branch**, not from the PR. That's deliberate: it's the trigger that gets write permissions and secrets, so GitHub won't let a PR swap in its own version of the workflow. Good for security, confusing when you're fixing the workflow. The PR always runs the old, broken version.

So you merge first and test after. To test, comment on any PR:

```bash
gh pr comment 2 --body "recheck"

```

`issue_comment` workflows also run from the default branch, which is now the fixed one.

## Gotcha: the first run after the fix fails anyway

The recheck ran with the new config (`branch: cla-signatures` showed up in the log, no more token error) and still failed:

```text
##[error]Committers of pull request 2 have to sign the CLA

```

The only committer on that PR was me, and I'm on the allowlist. So why?

Instead of guessing I read the action's source at the exact tag I was pinned to (`v2.6.1`). In `src/setupClaCheck.ts`, when the signature file doesn't exist yet (404), the action calls `createClaFileAndPRComment`. That function creates the file with an empty list:

```json
{
   "signedContributors": []
}

```

...and then, unconditionally:

```ts
throw new Error(
  `Committers of pull request ${context.issue.number} have to sign the CLA`
)

```

No allowlist check changes that. The run that creates the file always fails. After that the file exists, the normal path runs, the allowlist works. Second `recheck`:

```text
All contributors have signed the CLA 📝 ✅

```

Green. If you set this up fresh, just plan for one sacrificial `recheck`. Reading the source at the pinned version took two minutes and saved me from "fixing" a config that was already correct. Same lesson as in [when an AI agent invents CLI flags](/ai-agent-hallucinated-cli-flags/): check what the code actually does, not what you think it does.

That same function also tells you what happens if creating the file fails: "Make sure the branch where signatures are stored is NOT protected." So if you have branch protection rules or rulesets matching `cla-*` or `*`, exclude the signatures branch. I checked mine before merging:

```bash
gh api repos/example-org/my-project/branches/main/protection
gh api repos/example-org/my-project/rulesets

```

Nothing protected in my case, so no conflict.

## Gotcha: your wait loop grabs the old run

Small one, but it cost me a confused minute. I polled for the recheck result like this:

```bash
until s=$(gh run list --workflow cla.yml --event issue_comment -L 1 \
  --json status,conclusion,databaseId \
  --jq '.[0] | "\(.status) \(.conclusion) \(.databaseId)"'); \
  [ "${s%% *}" = completed ]; do sleep 5; done; echo "$s"

```

Right after commenting, the new run isn't listed yet. `-L 1` returns the *previous* run, which is already `completed`, so the loop exits instantly with the old failure. Fix: remember the old run ID and wait until the top entry is a different one:

```bash
OLD=<previous-run-id>
until s=$(gh run list --workflow cla.yml --event issue_comment -L 1 \
  --json status,conclusion,databaseId \
  --jq '.[0] | "\(.status) \(.conclusion) \(.databaseId)"'); \
  [ "${s##* }" != "$OLD" ] && [ "${s%% *}" = completed ]; do sleep 5; done; echo "$s"

```

Any "wait until done" check that can match stale state has the same problem. I wrote about the cron version of that in [the idempotency bug that uploaded one file 153 times](/idempotency-cron-automation-duplicate-uploads/).

## Side note: the check wasn't blocking anything

The first PR merged fine with the red CLA check. `gh pr view --json mergeStateStatus` said `UNSTABLE`, not `BLOCKED`, because `main` had no branch protection and the CLA check wasn't required. So for however long this was broken, an outside PR could have been merged without a signature, and nobody would have been stopped. For a dual-licensed project that's the one check that actually matters legally. If you rely on a CLA, make it a required status check, *after* you've seen it go green once. Otherwise you lock yourself out with a check that can't pass.

## Checklist

- Single repo? Drop `remote-organization-name` / `remote-repository-name` and the PAT. `GITHUB_TOKEN` plus `contents: write` is enough.
- Store signatures on a dedicated branch, create it before the first run, keep it unprotected.
- Grep for leftover secret names. Missing secrets fail silently as empty strings.
- Don't trust the check on the PR that changes a `pull_request_target` workflow. Merge, then `recheck`.
- The first run after the fix fails by design. Recheck once more.
- Make the CLA check required once it's green.

Fewer long-lived tokens is the same idea as everywhere else on a server: give things exactly the access they need, like in my [SSH hardening checklist](/ssh-hardening-ubuntu-checklist/) or when [setting up users with sudo and keys](/linux-user-management-adduser-sudo-ssh-keys/). One token less in my repo secrets, and a CLA check that finally does its job.

---

### Related posts

- [Supabase in React Native: Why Users Got Randomly Logged Out](https://blog.sudowl.com/supabase-react-native-random-logout-token-refresh/)
- [KeyHelp Let's Encrypt Race: Two Cert Jobs Took Apache Down for 21 Minutes](https://blog.sudowl.com/keyhelp-letsencrypt-race-apache-down/)
- [I Launched a Waitlist Page in One Night. Here's Everything That Broke](https://blog.sudowl.com/waitlist-page-one-night-self-hosted/)