Fix update_project to use custom GitHub token for cross-org project access #13276
+28
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
update_projecthandler fails when accessing Projects v2 in organizations different from the repository, throwing "Project not found or not accessible" despite a custom token being configured insafe-outputs.update-project.github-token.Root cause
The handler's
main()function doesn't accept thegithubClientparameter passed by the unified handler manager. It always uses the globalgithubobject (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 functionupdateProject(output, temporaryIdMap, githubClient)- Main handlerresolveProjectV2(projectInfo, projectNumberInt, github)- Project resolverlistAccessibleProjectsV2(projectInfo, github)- Project listerPattern applied:
All functions fall back to
global.githubfor backward compatibility. Existing tests pass without modification.Impact
Workflows with custom project tokens now work across organization boundaries:
Original prompt
💡 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.