-
Notifications
You must be signed in to change notification settings - Fork 0
codeql troubleshooting
GitHub Actions edited this page Feb 3, 2026
·
1 revision
When running github/codeql-action/init@v4, you may encounter this error:
Error: Encountered an error while trying to determine feature enablement: HttpError: Bad credentials - https://docs.github.com/rest
Warning: An unexpected error occurred when sending a status report: Bad credentials - https://docs.github.com/rest
-
Invalid or Expired GitHub Token
- The GITHUB_TOKEN may be expired or revoked
- The token doesn't have sufficient permissions
-
Insufficient Permissions
- Missing
security-events: writepermission in workflow - Missing
contents: readpermission in job
- Missing
-
Feature Enablement Check Failure
- CodeQL cannot communicate with GitHub API
- Organization or repository settings may restrict CodeQL
-
Token Scope Issues
- GITHUB_TOKEN doesn't have proper scopes
- Enterprise or organization policies may limit access
Ensure your workflow has the correct permissions. Update your workflow file:
permissions:
contents: write
pull-requests: read
actions: read
checks: write
statuses: write
security-events: write # Required for CodeQLFor the CodeQL job specifically:
codeql-analysis:
name: CodeQL Analysis
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
actions: readUse v3 or v4 of the CodeQL actions. The example shows v4 but v3 is more stable:
- name: Initialize CodeQL
uses: github/codeql-action/init@v3 # or @v4
with:
languages: javascript-typescript
build-mode: noneEnsure proper build-mode and language settings:
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: javascript-typescript
build-mode: none # For interpreted languages
queries: security-and-quality # Specify queries explicitlyIf feature enablement checks fail, add a simple initialization step:
- name: Initialize CodeQL with retry
uses: github/codeql-action/init@v3
with:
languages: javascript-typescript
build-mode: none
setup-python-dependencies: false- Go to your repository settings
- Navigate to "Code security and analysis" section
- Ensure "GitHub Advanced Security" is enabled
- Ensure "Code scanning / Default" is enabled
- Check organization policies aren't blocking CodeQL
# Verify the token has access
curl -H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/OWNER/REPO
# Check CodeQL enablement
curl -H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/OWNER/REPO/code-scanning/alertsThe unified-ci.yml workflow has been updated with:
- ✅ Required
security-events: writepermission - ✅ CodeQL job with proper permissions scope
- ✅ Correct action versions (
@v3) - ✅ Proper language and build-mode configuration
- ✅ Integration with final report
- ✅ Configuration file at
.github/codeql-config.yml
To test CodeQL configuration locally:
# Install CodeQL CLI
# Visit: https://github.com/github/codeql-cli-binaries/releases
# Create a database
codeql database create codeql-db --language=javascript-typescript
# Run analysis
codeql database analyze codeql-db \
--format=sarif-latest \
--output=results.sarif \
javascript-typescript| Parameter | Values | Notes |
|---|---|---|
languages |
javascript-typescript, python, java, cpp, csharp, go, ruby | Comma-separated for multiple |
build-mode |
none, autobuild, manual | Use 'none' for interpreted languages |
queries |
security-and-quality, security-extended | Determines analysis depth |
config-file |
path/to/config.yml | Optional configuration file |
The "Bad credentials" error can also occur due to:
- Rate limiting: GitHub API rate limits exceeded
- Organization policies: GHES (GitHub Enterprise Server) restrictions
- Team settings: Advanced Security not available
- Check GitHub Actions logs for full error details
- Review CodeQL documentation: https://codeql.github.com/docs/
- Visit: https://github.com/github/codeql-action/issues
- Check GitHub Community Support: https://github.community/
- ✅
.github/workflows/unified-ci.yml- Added CodeQL job - ✅
.github/codeql-config.yml- Created configuration file
- Verify all required permissions are set
- Check repository Code security settings
- Run workflow and monitor logs
- Review security alerts in repository
Les contributions sont bienvenues ! Voir CONTRIBUTING.md
This documentation is automatically synced from the main repository.