Skip to content

Commit 0f189de

Browse files
Tabonxclaude
andcommitted
fix(azure-devops): a failed policy read no longer caches empty checks
Azure detail answers a failed policy read with no checks, so seeding the checks cache from it hid the real state for the cache's 15 seconds. Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent e3234da commit 0f189de

2 files changed

Lines changed: 39 additions & 2 deletions

File tree

‎apps/server/src/pullRequest/PullRequestService.test.ts‎

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3075,7 +3075,11 @@ it.effect.each(["github", "azure-devops"])(
30753075
],
30763076
providers: [
30773077
fakePullRequestProvider(SourceControlProviderKind.make(provider), {
3078-
getChangeRequest: () => Effect.succeed(hostedChangeRequest("Description")),
3078+
getChangeRequest: () =>
3079+
Effect.succeed({
3080+
...hostedChangeRequest("Description"),
3081+
checks: [{ name: "build", status: "success", description: null, url: null }],
3082+
}),
30793083
getChangeRequestChecks: () =>
30803084
Effect.sync(() => {
30813085
reads += 1;
@@ -3105,6 +3109,37 @@ it.effect.each(["github", "azure-devops"])(
31053109
}),
31063110
);
31073111

3112+
it.effect("asks Azure for checks when its detail came back with none", () =>
3113+
Effect.gen(function* () {
3114+
let reads = 0;
3115+
const reference = { projectId: "p1" as ProjectId, repository: "web", number: 1 };
3116+
const service = yield* makeService({
3117+
projects: [
3118+
project({
3119+
id: "p1",
3120+
title: "web",
3121+
workspaceRoot: "/a",
3122+
repository: "web",
3123+
provider: "azure-devops",
3124+
}),
3125+
],
3126+
providers: [
3127+
fakePullRequestProvider(SourceControlProviderKind.make("azure-devops"), {
3128+
getChangeRequest: () => Effect.succeed(hostedChangeRequest("Description")),
3129+
getChangeRequestChecks: () =>
3130+
Effect.sync(() => {
3131+
reads += 1;
3132+
return { state: "open" as const, checks: [] };
3133+
}),
3134+
}),
3135+
],
3136+
});
3137+
yield* service.detail(reference);
3138+
yield* service.checks(reference);
3139+
expect(reads).toBe(1);
3140+
}),
3141+
);
3142+
31083143
it.effect("preserves check observation time on cache hits and advances it on refresh", () =>
31093144
Effect.gen(function* () {
31103145
let reads = 0;

‎apps/server/src/pullRequest/PullRequestService.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3101,8 +3101,10 @@ export const make = Effect.gen(function* () {
31013101
Effect.tap(
31023102
Effect.fn("PullRequestService.recordDetailStats")(function* (value: PullRequestDetail) {
31033103
// GitHub and Azure detail include the same checks; the checks TTL counts from their observation.
3104+
// Azure detail answers a failed policy read with no checks, which must not be cached.
31043105
if (
3105-
(value.provider === "github" || value.provider === "azure-devops") &&
3106+
(value.provider === "github" ||
3107+
(value.provider === "azure-devops" && value.checks.length > 0)) &&
31063108
value.observedAt !== undefined &&
31073109
!(yield* Cache.has(checksCache, key))
31083110
) {

0 commit comments

Comments
 (0)