Skip to content
TypeScript

fix(server): a repository on an unrecognized host no longer fails every PR status lookup (#19030)

AdEx-Partners-DEe0de586a077c
diff --git a/apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts b/apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts
index 697a83baa2a..dc5a6505170 100644
--- a/apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts
+++ b/apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts
@@ -207,6 +207,21 @@ it.effect("includes the request cwd when an unregistered provider is used", () =
}),
);
+it.effect("lists no change requests for a repository on an unrecognized host", () =>
+ Effect.gen(function* () {
+ const registry = yield* makeRegistry({
+ remotes: [{ name: "origin", url: "https://git.example.internal/team/repo.git" }],
+ });
+ const provider = yield* registry.resolve({ cwd: "/repo" });
+
+ assert.strictEqual(provider.kind, "unknown");
+ assert.deepStrictEqual(
+ yield* provider.listChangeRequests({ cwd: "/repo", headSelector: "master", state: "all" }),
+ [],
+ );
+ }),
+);
+
it.effect("retains VCS detection failures with structured cwd context", () =>
Effect.gen(function* () {
const cause = new VcsRepositoryDetectionError({
diff --git a/apps/server/src/sourceControl/SourceControlProviderRegistry.ts b/apps/server/src/sourceControl/SourceControlProviderRegistry.ts
index d185ba0cc0b..6109fe43c19 100644
--- a/apps/server/src/sourceControl/SourceControlProviderRegistry.ts
+++ b/apps/server/src/sourceControl/SourceControlProviderRegistry.ts
@@ -74,13 +74,18 @@ function unsupportedProvider(
): SourceControlProvider.SourceControlProvider["Service"] {
return SourceControlProvider.SourceControlProvider.of({
kind,
+ // A remote on a host no provider recognizes (or no remote at all) has no change
+ // requests T3 could know about. Answering with none keeps the status poller from
+ // failing, and warning, on every refresh of such a repository.
listChangeRequests: (input) =>
- new SourceControlProviderError({
- provider: kind,
- operation: "listChangeRequests",
- cwd: input.cwd,
- detail: `No ${kind} source control provider is registered.`,
- }),
+ kind === "unknown"
+ ? Effect.succeed([])
+ : new SourceControlProviderError({
+ provider: kind,
+ operation: "listChangeRequests",
+ cwd: input.cwd,
+ detail: `No ${kind} source control provider is registered.`,
+ }),
getChangeRequest: (input) =>
new SourceControlProviderError({
provider: kind,