fix: preserve pre-advisory provider status during compatibility advisory removal
When applyCompatibilityAdvisory overwrites a provider's status/message with compatibility information, the original values (e.g. from a genuine probe failure) were permanently lost. When a subsequent advisory removal or replacement occurred, removeExistingCompatibilityAdvisory would reset status to 'ready' instead of the original pre-advisory status. Fix by recording preAdvisoryStatus and preAdvisoryMessage in the advisory object when it is applied. removeExistingCompatibilityAdvisory now restores these saved values instead of unconditionally resetting to 'ready'/'disabled'. For old advisories without these fields, the fallback behavior is unchanged.
This commit is contained in:
3 files changed
+64
-2
No files matched your search
@@ -327,6 +327,52 @@ describe("provider compatibility", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it.effect("preserves genuine probe errors when the remote map relaxes a bundled advisory", () => {
|
||||
const bundledMessage =
|
||||
"This provider harness version 0.130.0 is known to be incompatible with this T3 Code release. Use 0.129.0.";
|
||||
const probeErrorMessage = "CLI health-check failed: process exited with code 1";
|
||||
const remoteDocument = {
|
||||
version: 1,
|
||||
policies: [
|
||||
{
|
||||
t3CodeRange: ">=0.0.0",
|
||||
driver: "codex",
|
||||
recommendedRange: ">=0.130.0",
|
||||
recommendedVersion: "0.130.0",
|
||||
ranges: [{ status: "supported", range: ">=0.130.0" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const enriched = yield* enrichProviderSnapshotWithCompatibilityAdvisory({
|
||||
...baseProvider,
|
||||
status: "error",
|
||||
message: bundledMessage,
|
||||
compatibilityAdvisory: {
|
||||
status: "broken",
|
||||
severity: "error",
|
||||
currentVersion: "0.130.0",
|
||||
message: bundledMessage,
|
||||
recommendedRange: "<0.130.0",
|
||||
recommendedVersion: "0.129.0",
|
||||
ranges: [{ status: "broken", range: ">=0.130.0" }],
|
||||
preAdvisoryStatus: "error",
|
||||
preAdvisoryMessage: probeErrorMessage,
|
||||
},
|
||||
}).pipe(
|
||||
Effect.provideService(
|
||||
HttpClient.HttpClient,
|
||||
jsonHttpClient(() => ({ payload: remoteDocument })),
|
||||
),
|
||||
);
|
||||
|
||||
expect(enriched.status).toBe("error");
|
||||
expect(enriched.message).toBe(probeErrorMessage);
|
||||
expect(enriched.compatibilityAdvisory).toMatchObject({ status: "supported" });
|
||||
});
|
||||
});
|
||||
|
||||
it.effect("falls back to the bundled map when the remote compatibility fetch fails", () =>
|
||||
Effect.gen(function* () {
|
||||
const enriched = yield* enrichProviderSnapshotWithCompatibilityAdvisory({
|
||||
|
||||
@@ -325,13 +325,19 @@ function applyCompatibilityAdvisory<Snapshot extends ProviderCompatibilitySnapsh
|
||||
? "warning"
|
||||
: baseSnapshot.status;
|
||||
|
||||
const advisoryWithPreState: ServerProviderCompatibilityAdvisory = {
|
||||
...compatibilityAdvisory,
|
||||
preAdvisoryStatus: baseSnapshot.status,
|
||||
...(baseSnapshot.message ? { preAdvisoryMessage: baseSnapshot.message } : {}),
|
||||
};
|
||||
|
||||
return {
|
||||
...baseSnapshot,
|
||||
status,
|
||||
...(compatibilityMessage || baseSnapshot.message
|
||||
? { message: compatibilityMessage ?? baseSnapshot.message }
|
||||
: {}),
|
||||
compatibilityAdvisory,
|
||||
compatibilityAdvisory: advisoryWithPreState,
|
||||
} as Snapshot;
|
||||
}
|
||||
|
||||
@@ -349,11 +355,19 @@ function removeExistingCompatibilityAdvisory<Snapshot extends ProviderCompatibil
|
||||
: undefined;
|
||||
if (compatibilityMessage && baseSnapshot.message === compatibilityMessage) {
|
||||
const { message: _message, ...snapshotWithoutCompatibilityMessage } = baseSnapshot;
|
||||
const restoredStatus =
|
||||
existingCompatibilityAdvisory.preAdvisoryStatus ?? (snapshot.enabled ? "ready" : "disabled");
|
||||
return {
|
||||
...snapshotWithoutCompatibilityMessage,
|
||||
status: snapshot.enabled ? "ready" : "disabled",
|
||||
status: restoredStatus,
|
||||
...(existingCompatibilityAdvisory.preAdvisoryMessage
|
||||
? { message: existingCompatibilityAdvisory.preAdvisoryMessage }
|
||||
: {}),
|
||||
} as Snapshot;
|
||||
}
|
||||
if (existingCompatibilityAdvisory.preAdvisoryStatus !== undefined) {
|
||||
return { ...baseSnapshot, status: existingCompatibilityAdvisory.preAdvisoryStatus } as Snapshot;
|
||||
}
|
||||
return baseSnapshot as Snapshot;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,6 +163,8 @@ export const ServerProviderCompatibilityAdvisory = Schema.Struct({
|
||||
ranges: Schema.Array(ServerProviderCompatibilityRange).pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed([])),
|
||||
),
|
||||
preAdvisoryStatus: Schema.optionalKey(ServerProviderState),
|
||||
preAdvisoryMessage: Schema.optionalKey(TrimmedNonEmptyString),
|
||||
});
|
||||
export type ServerProviderCompatibilityAdvisory = typeof ServerProviderCompatibilityAdvisory.Type;
|
||||
|
||||
|
||||
Reference in new issue
Block a user