Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

The update_project handler fails when accessing Projects v2 in organizations different from the repository, throwing "Project not found or not accessible" despite a custom token being configured in safe-outputs.update-project.github-token.

Root cause

The handler's main() function doesn't accept the githubClient parameter passed by the unified handler manager. It always uses the global github object (default GITHUB_TOKEN), which lacks cross-org project permissions.

Other project handlers (create_project, create_project_status_update) already implement this pattern correctly.

Changes

Updated function signatures to accept GitHub client:

  • main(config, githubClient) - Factory function
  • updateProject(output, temporaryIdMap, githubClient) - Main handler
  • resolveProjectV2(projectInfo, projectNumberInt, github) - Project resolver
  • listAccessibleProjectsV2(projectInfo, github) - Project lister

Pattern applied:

async function main(config = {}, githubClient = null) {
  const github = githubClient || global.github;
  if (!github) {
    throw new Error("GitHub client required");
  }
  // ... use github for all GraphQL calls
}

All functions fall back to global.github for backward compatibility. Existing tests pass without modification.

Impact

Workflows with custom project tokens now work across organization boundaries:

safe-outputs:
  update-project:
    github-token: ${{ secrets.CROSS_ORG_PROJECT_TOKEN }}
    project: "https://github.com/orgs/other-org/projects/1"
Original prompt

Why does this fail:
{
"content_type": "draft_issue",
"draft_body": "Test draft issue for smoke test validation",
"draft_title": "Smoke Test Draft Issue - Run 21590911510",
"fields": {
"Priority": "High",
"Status": "Todo"
},
"project": "https://github.com/orgs/github-agentic-workflows/projects/1",
"type": "update_project"
}
❌ Update Project - Failed (Message 2)
Update Project
Error: Project #1 not found or not accessible for org github-agentic-workflows. (totalCount=0) Accessible Projects v2: (none nodes=0 (null=0), edges=0 (nullNode=0))
See safe outputs: https://github.com/githubnext/gh-aw/actions/runs/21590911510


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
@mnkiefer mnkiefer marked this pull request as ready for review February 2, 2026 13:25
@mnkiefer
Copy link
Contributor

mnkiefer commented Feb 2, 2026

@copilot Recompile workflows

Copilot AI changed the title [WIP] Fix project access issue in draft issue update Fix update_project to use custom GitHub token for cross-org project access Feb 2, 2026
Copilot AI requested a review from mnkiefer February 2, 2026 13:28
Copy link
Contributor Author

Copilot AI commented Feb 2, 2026

@copilot Recompile workflows

Workflows recompiled successfully. All 149 workflow files compiled with no changes to commit - the .lock.yml files are already up to date with the JavaScript handler changes.

@mnkiefer mnkiefer merged commit 920bb71 into main Feb 2, 2026
160 checks passed
@mnkiefer mnkiefer deleted the copilot/fix-update-project-error branch February 2, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants