chdsbd / kodiak

🔮 A bot to automatically update and merge GitHub PRs
https://kodiakhq.com
GNU Affero General Public License v3.0
1.03k stars 65 forks source link

"Require merge queue" branch protection rule is incompatible with automerge feature #871

Open vitalyster opened 1 year ago

vitalyster commented 1 year ago

My config:

# .kodiak.toml
version = 1

[merge]
method = "rebase_fast_forward"
[approve]
# note: remove the "[bot]" suffix from GitHub Bot usernames.
# Instead of "dependabot[bot]" use "dependabot".
auto_approve_usernames = ["dependabot"]
vitalyster commented 1 year ago

With method="rebase" I see:

API call 'pull_request/merge' failed with HTTP status '405' and response: 'b'{"message":"Server Error","documentation_url":"[https://docs.github.com/articles/about-protected-branches"}\](https://docs.github.com/articles/about-protected-branches%22%7D%5C)''
vitalyster commented 1 year ago

Same without method option

chdsbd commented 1 year ago

Hey @vitalyster, do you still get a "Server Error" from the GitHub API?

GitHub's API can be flaky sometime, but will usually resolve itself. Are you still able to replicate this issue?

vitalyster commented 1 year ago

@chdsbd still the same problem right now and that happens last 2-3 months, kodiak bot is unable to merge PRs most of the time

chdsbd commented 1 year ago

@vitalyster Is the repository public?

vitalyster commented 1 year ago

@chdsbd see this one from example

chdsbd commented 1 year ago

@vitalyster Thanks, I see this happening on other repositories too occasionally. I'm going to take a closer look and then open a ticket with GitHub Support

chdsbd commented 1 year ago

I've opened a support ticket with GitHub Support and will let you know what I hear from them

Here's the Curl output for context:

curl --request PUT \
  --url https://api.github.com/repos/BombusMod/BombusMod/pulls/167/merge \
  --header 'Accept: application/vnd.github.antiope-preview+json,application/vnd.github.merge-info-preview+json' \
  --header 'Authorization: Bearer ghs_redacted' \
  --header 'Content-Type: application/json' \
  --data '{"merge_method": "rebase"}' -vvv
*   Trying 140.82.112.5:443...
* Connected to api.github.com (140.82.112.5) port 443 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* [CONN-0-0][CF-SSL] (304) (OUT), TLS handshake, Client hello (1):
* [CONN-0-0][CF-SSL] (304) (IN), TLS handshake, Server hello (2):
* [CONN-0-0][CF-SSL] (304) (IN), TLS handshake, Unknown (8):
* [CONN-0-0][CF-SSL] (304) (IN), TLS handshake, Certificate (11):
* [CONN-0-0][CF-SSL] (304) (IN), TLS handshake, CERT verify (15):
* [CONN-0-0][CF-SSL] (304) (IN), TLS handshake, Finished (20):
* [CONN-0-0][CF-SSL] (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256
* ALPN: server accepted h2
* Server certificate:
*  subject: C=US; ST=California; L=San Francisco; O=GitHub, Inc.; CN=*.github.com
*  start date: Feb 16 00:00:00 2023 GMT
*  expire date: Mar 15 23:59:59 2024 GMT
*  subjectAltName: host "api.github.com" matched cert's "*.github.com"
*  issuer: C=US; O=DigiCert Inc; CN=DigiCert TLS Hybrid ECC SHA384 2020 CA1
*  SSL certificate verify ok.
* Using HTTP2, server supports multiplexing
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* h2h3 [:method: PUT]
* h2h3 [:path: /repos/BombusMod/BombusMod/pulls/167/merge]
* h2h3 [:scheme: https]
* h2h3 [:authority: api.github.com]
* h2h3 [user-agent: curl/7.87.0]
* h2h3 [accept: application/vnd.github.antiope-preview+json,application/vnd.github.merge-info-preview+json]
* h2h3 [authorization: Bearer ghs_redacted]
* h2h3 [content-type: application/json]
* h2h3 [content-length: 26]
* Using Stream ID: 1 (easy handle 0x159011400)
> PUT /repos/BombusMod/BombusMod/pulls/167/merge HTTP/2
> Host: api.github.com
> user-agent: curl/7.87.0
> accept: application/vnd.github.antiope-preview+json,application/vnd.github.merge-info-preview+json
> authorization: Bearer ghs_redacted
> content-type: application/json
> content-length: 26
> 
* We are completely uploaded and fine
< HTTP/2 405 
< server: GitHub.com
< date: Tue, 04 Apr 2023 00:42:15 GMT
< content-type: application/json; charset=utf-8
< content-length: 116
< x-github-media-type: github.v3; param=antiope-preview; format=json, github.merge-info-preview; format=json
< x-github-api-version-selected: 2022-11-28
< x-ratelimit-limit: 5000
< x-ratelimit-remaining: 4997
< x-ratelimit-reset: 1680572487
< x-ratelimit-used: 3
< x-ratelimit-resource: core
< access-control-expose-headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
< access-control-allow-origin: *
< strict-transport-security: max-age=31536000; includeSubdomains; preload
< x-frame-options: deny
< x-content-type-options: nosniff
< x-xss-protection: 0
< referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
< content-security-policy: default-src 'none'
< vary: Accept-Encoding, Accept, X-Requested-With
< x-github-request-id: CB17:1B25:47082E:927730:642B7267
< 
{
  "message": "Server Error",
  "documentation_url": "https://docs.github.com/articles/about-protected-branches"
}
* Connection #0 to host api.github.com left intact  
vitalyster commented 1 year ago

Still an issue in all my repositories. Maybe they change API and that method is really does not exists?

vitalyster commented 1 year ago

Well, I checked API documentation and everything looks correct...

chdsbd commented 1 year ago

Hi @vitalyster

I'm still waiting for a response from GitHub support. I feel like their support times have gotten worse since their layoff.

vitalyster commented 1 year ago

@chdsbd found the solution. After comparing broken repos and working repos I uncheck "require merge queues (beta)" and PRs now merged correctly.

olegshilov commented 5 months ago

Is there any way to get kodiak work with merge queue?

chdsbd commented 5 months ago

@olegshilov Kodiak doesn't support merging with the GitHub Merge Queue. We could update Kodiak to support it using these APIs: https://github.blog/changelog/2023-04-19-pull-request-merge-queue-public-beta-api-support-and-recent-fixes/

This is where we call the merge APIs in Kodiak:

https://github.com/chdsbd/kodiak/blob/729e64dbc1211117a1d83aaccc0bcbd0967e550a/bot/kodiak/evaluation.py#L1119-L1140