使用octokit.net版本0.50.0 (目前的最新版本)创建一个从特性分支branch1到主服务器的拉请求。
如果特性分支存在.github目录,Octokit库将引发验证错误。
如果branch1有.any_other_dir_name或.github111,则创建拉请求有效,但只有在特性分支添加了.github dir时才会失败。
代码:
var client = new GitHubClient(
new ProductHeaderValue("branch1"),
new InMemoryCredentialStore(new Credentials(accessToken, AuthenticationType.Oauth)),
gheURI);
await client.PullRequest.Create(remote.Id, new NewPullRequest(prTitle, "branch1", "master"));堆栈跟踪:
Octokit.ApiValidationException: Validation Failed
at Octokit.Connection.HandleErrors(IResponse response) in /home/runner/work/octokit.net/octokit.net/Octokit/Http/Connection.cs:line 703
at Octokit.Connection.RunRequest(IRequest request, CancellationToken cancellationToken) in
.
.
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
{"message":"Validation Failed","errors":[{"resource":"PullRequest","field":"head","code":"invalid"}],"documentation_url":"https://docs.github.com/enterprise/3.1/rest/reference/pulls#create-a-pull-request"}有什么想法吗?
发布于 2022-01-06 17:32:47
想出了解决办法。原因是“工作流”范围丢失。
工作流-授予添加和更新GitHub操作工作流文件的能力。如果相同的文件(具有相同的路径和内容)存在于同一存储库中的另一个分支上,则可以在没有此作用域的情况下提交工作流文件。工作流文件可以公开可能具有不同范围集的GITHUB_TOKEN。有关详细信息,请参阅“工作流中的身份验证”。
来自https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps
https://stackoverflow.com/questions/70599622
复制相似问题