fix(web): links to issues no longer strand the pull request viewer (#14242)
This commit is contained in:
1 parent
2b8bb0c188
commit
7bc161f869
12 files changed
+73
-6
No files matched your search
@@ -117,6 +117,7 @@ export function azureDevOpsProviderFailure(
|
||||
if (error._tag === "AzureDevOpsCliUnavailableError") return { reason: "missing-tool" };
|
||||
if (error._tag === "AzureDevOpsCliAuthenticationError") return { reason: "unauthenticated" };
|
||||
if (error._tag === "AzureDevOpsCliRateLimitError") return { reason: "rate-limited" };
|
||||
if (error._tag === "AzureDevOpsPullRequestNotFoundError") return { reason: "not-found" };
|
||||
return { reason: "failed" };
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,12 @@ export function bitbucketProviderFailure(
|
||||
...(error.retryAt === undefined ? {} : { retryAt: error.retryAt }),
|
||||
};
|
||||
}
|
||||
if (
|
||||
(error._tag === "BitbucketResponseError" || error._tag === "BitbucketResponseBodyReadError") &&
|
||||
error.status === 404
|
||||
) {
|
||||
return { reason: "not-found" };
|
||||
}
|
||||
return { reason: "failed" };
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,9 @@ export const make = Effect.gen(function* () {
|
||||
? "unauthenticated"
|
||||
: error.reason === "rate-limit"
|
||||
? "rate-limited"
|
||||
: "failed",
|
||||
: error.reason === "not-found"
|
||||
? "not-found"
|
||||
: "failed",
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -115,6 +115,7 @@ export function gitHubProviderFailure(
|
||||
if (error._tag === "SourceControlRateLimitPausedError") {
|
||||
return { reason: "rate-limited", retryAt: error.retryAt };
|
||||
}
|
||||
if (error._tag === "GitHubPullRequestNotFoundError") return { reason: "not-found" };
|
||||
return { reason: "failed" };
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ export function gitLabProviderFailure(
|
||||
if (error._tag === "GitLabCliUnavailableError") return { reason: "missing-tool" };
|
||||
if (error._tag === "GitLabCliAuthenticationError") return { reason: "unauthenticated" };
|
||||
if (error._tag === "GitLabCliRateLimitError") return { reason: "rate-limited" };
|
||||
if (error._tag === "GitLabMergeRequestNotFoundError") return { reason: "not-found" };
|
||||
return { reason: "failed" };
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,13 @@ export class PullRequestProviderError extends Schema.TaggedError<PullRequestProv
|
||||
{
|
||||
provider: SourceControlProviderKindSchema,
|
||||
operation: Schema.String,
|
||||
reason: Schema.Literals(["missing-tool", "unauthenticated", "rate-limited", "failed"]),
|
||||
reason: Schema.Literals([
|
||||
"missing-tool",
|
||||
"unauthenticated",
|
||||
"rate-limited",
|
||||
"not-found",
|
||||
"failed",
|
||||
]),
|
||||
detail: Schema.String,
|
||||
retryAt: Schema.optional(Schema.Number),
|
||||
cause: Schema.optional(Schema.Defect()),
|
||||
|
||||
@@ -4815,6 +4815,33 @@ it.effect("does not let a still-cached detail overwrite a fresher linked summary
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("tells the client when the host has no pull request under that number", () =>
|
||||
Effect.gen(function* () {
|
||||
const reference = { projectId: "p1" as ProjectId, repository: "acme/web", number: 121 };
|
||||
const service = yield* makeService({
|
||||
projects: [project({ id: "p1", title: "web", workspaceRoot: "/a", repository: "acme/web" })],
|
||||
providers: [
|
||||
fakeProvider("github", {
|
||||
getChangeRequest: () =>
|
||||
Effect.fail(
|
||||
new PullRequestProviderError({
|
||||
provider: "github",
|
||||
operation: "getChangeRequest",
|
||||
reason: "not-found",
|
||||
detail: "Pull request not found. Check the PR number or URL and try again.",
|
||||
}),
|
||||
),
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const error = yield* Effect.flip(service.detail(reference));
|
||||
|
||||
assert.strictEqual(error._tag, "PullRequestOperationError");
|
||||
assert.strictEqual(error._tag === "PullRequestOperationError" && error.reason, "not-found");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("keeps recent detail on a transient refresh failure but not after invalidation", () =>
|
||||
Effect.gen(function* () {
|
||||
let failing = false;
|
||||
|
||||
@@ -477,7 +477,12 @@ function toPullRequestError(
|
||||
return (error) =>
|
||||
isProviderUnusable(error)
|
||||
? toUnavailableError(error)
|
||||
: new PullRequestOperationError({ operation, detail: error.detail, cause: error });
|
||||
: new PullRequestOperationError({
|
||||
operation,
|
||||
detail: error.detail,
|
||||
...(error.reason === "not-found" ? { reason: "not-found" as const } : {}),
|
||||
cause: error,
|
||||
});
|
||||
}
|
||||
|
||||
function withRateLimitBackoff(
|
||||
|
||||
Reference in new issue
Block a user