Skip to content

Commit 40b2291

Browse files
committed
fix(server): preserve structured Codex download status
1 parent b6335a7 commit 40b2291

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

‎apps/server/src/provider/CodexInstallation.ts‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,14 @@ export class CodexInstallationError extends Schema.TaggedError<CodexInstallation
103103
{
104104
operation: Schema.String,
105105
detail: Schema.String,
106+
httpStatus: Schema.optional(Schema.Number),
106107
cause: Schema.optional(Schema.Defect()),
107108
},
108109
) {
109110
override get message() {
110-
return this.detail;
111+
return this.httpStatus === undefined
112+
? this.detail
113+
: `The Codex download server returned HTTP ${this.httpStatus}. Try again later.`;
111114
}
112115
}
113116
const isInstallationError = Schema.is(CodexInstallationError);
@@ -565,14 +568,19 @@ export const makeCodexInstallation = Effect.fn("makeCodexInstallation")(function
565568
},
566569
Effect.scoped,
567570
Effect.catchTags({
568-
HttpClientError: (cause) =>
569-
installationError(
570-
"download",
571-
cause.reason._tag === "StatusCodeError"
572-
? `The Codex download server returned HTTP ${cause.reason.response.status}. Try again later.`
573-
: "The Codex download was interrupted. Check your internet connection, then retry installation.",
571+
HttpClientError: (cause) => {
572+
const httpStatus =
573+
cause.reason._tag === "StatusCodeError" ? cause.reason.response.status : undefined;
574+
return new CodexInstallationError({
575+
operation: "download",
576+
detail:
577+
httpStatus === undefined
578+
? "The Codex download was interrupted. Check your internet connection, then retry installation."
579+
: "The Codex download server returned an HTTP error. Try again later.",
580+
...(httpStatus === undefined ? {} : { httpStatus }),
574581
cause,
575-
),
582+
});
583+
},
576584
}),
577585
Effect.mapError(
578586
wrapFailure(
@@ -620,7 +628,7 @@ export const makeCodexInstallation = Effect.fn("makeCodexInstallation")(function
620628
message: cancelled
621629
? "Installation cancelled. The previous runtime is unchanged."
622630
: Option.isSome(error)
623-
? error.value.detail
631+
? error.value.message
624632
: "Could not finish the Codex installation. Check disk space and directory access.",
625633
} satisfies ProviderInstallState;
626634
})

‎apps/server/src/provider/providerInstallation.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const makeProviderInstallation = Effect.fn("makeProviderInstallation")(fu
103103
| AntigravityInstallation.AntigravityInstallationError
104104
| CodexInstallation.CodexInstallationError,
105105
) =>
106-
new ProviderSetupError({ instanceId, operation: error.operation, detail: error.detail });
106+
new ProviderSetupError({ instanceId, operation: error.operation, detail: error.message });
107107

108108
const start = Effect.fn("ProviderInstallation.start")(function* (input: ProviderSetupInput) {
109109
const { installation } = yield* requireInstance(input.instanceId, "install", true);

0 commit comments

Comments
 (0)