Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 27, 2025

The workflow fails with "Bad credentials" (401) when fetching repository labels because the token fallback expression evaluates incorrectly when CUSTOM_GITHUB_TOKEN is undefined.

Changes

  • Fix token assignment in .github/workflows/add-files-changed-label.yml to properly check for token existence before fallback

Before:

GITHUB_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}

After:

GITHUB_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN != '' && secrets.CUSTOM_GITHUB_TOKEN || github.token }}

The || operator doesn't handle undefined secrets correctly. The fixed expression explicitly checks if CUSTOM_GITHUB_TOKEN exists before using it, otherwise falls back to github.token (the built-in Actions token).

Original prompt

fix github action to add file count - Run echo "Starting Files Changed Label workflow for PR #$PR_NUMBER in $REPO_OWNER/$REPO_NAME"
##[debug]/usr/bin/bash -e /home/runner/work/_temp/13151e4e-0a01-4a02-b754-050b7eda6cfb.sh
Starting Files Changed Label workflow for PR #4666 in OWASP-BLT/BLT
Fetching files changed information...
Files changed in PR #4666: 3
Determined label: files-changed: 3 with color: fbca04
Checking if label exists in repository...
Error: Failed to fetch repository labels. Response: {
"message": "Bad credentials",
"documentation_url": "https://docs.github.com/rest",
"status": "401"
}


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 27, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Co-authored-by: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix GitHub Action to add file count label Fix token fallback in add-files-changed-label workflow Oct 27, 2025
Copilot AI requested a review from DonnieBLT October 27, 2025 16:03
Copilot finished work on behalf of DonnieBLT October 27, 2025 16:03
@DonnieBLT DonnieBLT closed this Nov 16, 2025
@DonnieBLT DonnieBLT deleted the copilot/fix-github-action-file-count branch November 16, 2025 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants