Skip to content

Lock file generator drops permissions on agent job and omits them on detection job #23572

@pholleran

Description

@pholleran

Issue Draft for github/gh-aw

Title: Lock file generator drops permissions on agent job and omits them on detection job


Description

The lock file generator produces insufficient permissions: for the agent and detection jobs when the source .md file specifies permissions: read-all with features: copilot-requests: true.

The agent job only receives copilot-requests: write — all other scopes from read-all are dropped. The detection job receives no permissions: block at all.

Source configuration

# repo-assist.md
permissions: read-all

features:
  copilot-requests: true

What the lock file generates

Job contents issues pull-requests discussions copilot-requests
activation read write write write
agent ❌ missing ❌ missing ❌ missing ❌ missing write
detection (no permissions block at all — inherits workflow-level {}) ❌ missing
push_repo_memory write
conclusion write write

Failures observed

1. agent job — checkout fails (no contents: read)

##[error]fatal: repository 'https://github.com/octodemo/octocat_supply-symmetrical-orbit/' not found
The process '/usr/bin/git' failed with exit code 128

actions/checkout uses the default GITHUB_TOKEN, which only has copilot-requests: write. Three retries, all failed.

2. agent job — GraphQL API fails (no issues: read)

GraphQL: Resource not accessible by integration (repository.issues)

The "Fetch repo data for task weighting" step runs gh issue list and gh pr list, which require issues and pull-requests scopes.

3. detection job — copilot-cli auth fails (no copilot-requests: write)

Error: Authentication failed (Request ID: E828:18E55B:99C31A:A99D84:69CAB689)
Your GitHub token may be invalid, expired, or lacking the required permissions.

The detection job has no permissions: block, so it inherits the workflow-level permissions: {} (empty). copilot-cli uses COPILOT_GITHUB_TOKEN: ${{ github.token }} which has zero scopes.

Expected behavior

  • The agent job should receive the workflow-level permissions: read-all scopes merged with copilot-requests: write from features:, not replaced by it.
  • The detection job should receive at minimum copilot-requests: write since it runs copilot-cli.

Workaround applied

I manually patched the lock file to add the missing permissions across three commits:

  1. Added contents: read to the agent job — fixed the checkout failure
  2. Added issues: write, pull-requests: write, discussions: write to the agent job — fixed the GraphQL API failure
  3. Added copilot-requests: write to the detection job — fixed the copilot-cli auth failure

Agent job (final):

permissions:
  contents: read
  copilot-requests: write
  discussions: write
  issues: write
  pull-requests: write

Detection job (added):

permissions:
  copilot-requests: write

Additional note

The agent job may also need contents: write (not just read) since it creates PRs with code changes. My workaround uses read for now, but this could surface as another failure.

References

  • Source: .github/workflows/repo-assist.md
  • Lock file: .github/workflows/repo-assist.lock.yml

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions