| ... | ... | @@ -107,6 +107,16 @@ export type BitbucketPullRequestApiError = |
| 107 | 107 | | BitbucketRepositoryUnsupportedError |
| 108 | 108 | | BitbucketDiffCommitError; |
| 109 | 109 | |
| 110 | /** |
| 111 | * `/user/permissions/repositories` answering CHANGE-2770's removal notice rather than a |
| 112 | * permission — Bitbucket sends this for every account now, not only ones it would have refused. |
| 113 | */ |
| 114 | function isRepositoryPermissionRemovedError( |
| 115 | error: BitbucketPullRequestApiError, |
| 116 | ): error is BitbucketApi.BitbucketResponseError { |
| 117 | return error._tag === "BitbucketResponseError" && error.status === 410; |
| 118 | } |
| 119 | |
| 110 | 120 | /** |
| 111 | 121 | * Bitbucket's own ceiling. Asking for more does not fail — it answers with an empty page and no |
| 112 | 122 | * error at all, so this is a number to respect rather than to push against. |
| ... | ... | @@ -553,6 +563,13 @@ export const make = Effect.gen(function* () { |
| 553 | 563 | // Nothing on the repository, the pull request or the workspace states what the credentials |
| 554 | 564 | // may do, so this endpoint is the one request Bitbucket makes unavoidable. It is asked |
| 555 | 565 | // alongside the reads the detail was already making, so it costs no round trip of its own. |
| 566 | // |
| 567 | // Bitbucket permanently removed this endpoint (CHANGE-2770): every account now gets HTTP 410 |
| 568 | // in place of an answer, whatever it may do. That is the deprecated-endpoint signal, not a |
| 569 | // permission being refused, so it is read the same way an unreachable read already is |
| 570 | // elsewhere — as a permission that could not be learned, which grants rather than blocks, and |
| 571 | // leaves the actual merge or write to say why if the account may not do it. Any other failure |
| 572 | // (a bad token, a network fault, an unreadable body) still fails as it did before. |
| 556 | 573 | getRepositoryPermission: (input) => |
| 557 | 574 | withRepository(input.repository, () => |
| 558 | 575 | readPage({ |
| ... | ... | @@ -562,7 +579,7 @@ export const make = Effect.gen(function* () { |
| 562 | 579 | )}`, |
| 563 | 580 | decode: decodeRepositoryPermissionJson, |
| 564 | 581 | }), |
| 565 | | ), |
| 582 | ).pipe(Effect.catchIf(isRepositoryPermissionRemovedError, () => Effect.succeed(true))), |
| 566 | 583 | |
| 567 | 584 | getPullRequestDiff: (input) => |
| 568 | 585 | input.commit !== undefined && !isCommitSha(input.commit) |