fix: keep connection error messages structural

Co-authored-by: codex <[email protected]>
This commit is contained in:
Julius Marmingeandcodex committed 2026-06-20 20:07:53 -07:00
1 parent a7d56b3e9d
commit 8fd276f69e
9 files changed
+23 -51

No files matched your search

@@ -58,7 +58,7 @@ export function useConnectionController() {
environment: entry.environment,
availability: entry.availability,
status: Option.getOrNull(entry.status),
error: Option.getOrNull(entry.error)?.message ?? null,
error: Option.getOrNull(entry.error)?.detail ?? null,
traceId: Option.getOrNull(entry.error)?.traceId ?? null,
})),
[discovery.environments],
@@ -112,7 +112,7 @@ export function useConnectionController() {
relayDiscovery: {
isRefreshing: discovery.refreshing,
isOffline: discovery.offline,
error: Option.getOrNull(discovery.error)?.message ?? null,
error: Option.getOrNull(discovery.error)?.detail ?? null,
errorTraceId: Option.getOrNull(discovery.error)?.traceId ?? null,
},
connectPairingUrl,
@@ -1837,7 +1837,7 @@ function ConfiguredCloudRemoteEnvironmentRows({
? "Relay offline"
: availability === "checking"
? "Checking relay status"
: (Option.getOrNull(error)?.message ?? "Relay status unavailable")
: (Option.getOrNull(error)?.detail ?? "Relay status unavailable")
}
/>
<p className="truncate text-sm font-medium">{environment.label}</p>
@@ -1854,7 +1854,7 @@ function ConfiguredCloudRemoteEnvironmentRows({
? "Available · Relay offline"
: availability === "checking"
? "Available · Checking relay status…"
: (Option.getOrNull(error)?.message ?? "Available · Relay status unavailable")}
: (Option.getOrNull(error)?.detail ?? "Available · Relay status unavailable")}
</p>
</div>
<Button
+4 -2
View File
@@ -104,7 +104,8 @@ describe("desktop SSH pairing", () => {
).pipe(Effect.flip);
expect(error).toBeInstanceOf(ConnectionTransientError);
expect(error.message).toBe("Could not prepare the SSH environment.");
expect(error.detail).toBe("Could not prepare the SSH environment.");
expect(error.message).toBe("Connection attempt failed (remote-unavailable).");
expect(error.message).not.toContain(cause.message);
expect(error.cause).toBe(cause);
}),
@@ -126,9 +127,10 @@ describe("desktop SSH pairing", () => {
).pipe(Effect.flip);
expect(error).toBeInstanceOf(ConnectionBlockedError);
expect(error.message).toBe(
expect(error.detail).toBe(
"SSH authentication did not complete for [email protected].",
);
expect(error.message).toBe("Connection attempt blocked (authentication).");
expect(error.cause).toBe(cancellation);
expect(cancellation.cause).toBe(promptCause);
}),
+3 -2
View File
@@ -70,7 +70,8 @@ describe("makeCatalogBackend", () => {
const error = yield* backend.write("{}").pipe(Effect.flip);
expect(error).toBeInstanceOf(ConnectionTransientError);
expect(error.message).toContain("Desktop secure storage is unavailable");
expect(error.detail).toContain("Desktop secure storage is unavailable");
expect(error.message).toBe("Connection attempt failed (remote-unavailable).");
expect(error.cause).toMatchObject({ _tag: "DesktopSecureStorageUnavailableError" });
expect(setConnectionCatalog).toHaveBeenCalledWith("{}");
}),
@@ -95,7 +96,7 @@ describe("makeCatalogBackend", () => {
backend: "desktop-secure-storage",
cause,
});
expect(error.message).toBe("Could not save local connection data.");
expect(error.detail).toBe("Could not save local connection data.");
expect(error.message).not.toContain(cause.message);
}),
);
@@ -397,6 +397,9 @@ describe("EnvironmentConnector", () => {
operation: "status",
reason: "endpoint_provider_not_managed",
});
expect(result.failure.message).toBe(
"Environment 'env-connector-test' is not authorized for status (endpoint_provider_not_managed).",
);
}
}
expect(requestCount).toBe(0);
@@ -58,29 +58,6 @@ export const EnvironmentConnectNotAuthorizedReason = Schema.Literals([
export type EnvironmentConnectNotAuthorizedReason =
typeof EnvironmentConnectNotAuthorizedReason.Type;
function environmentConnectNotAuthorizedReasonMessage(
reason: EnvironmentConnectNotAuthorizedReason,
): string {
switch (reason) {
case "client_proof_key_thumbprint_missing":
return "the client proof key thumbprint is missing";
case "environment_link_not_found":
return "no active environment link was found";
case "endpoint_provider_not_managed":
return "the linked endpoint is not relay-managed";
case "managed_endpoint_allocation_not_found":
return "no managed endpoint allocation was found";
case "managed_endpoint_base_domain_not_configured":
return "the managed endpoint base domain is not configured";
case "managed_endpoint_allocation_not_ready":
return "the managed endpoint allocation is incomplete";
case "managed_endpoint_hostname_invalid":
return "the managed endpoint hostname is invalid";
case "managed_endpoint_mismatch":
return "the linked endpoint does not match its managed allocation";
}
}
export class EnvironmentConnectNotAuthorized extends Schema.TaggedErrorClass<EnvironmentConnectNotAuthorized>()(
"EnvironmentConnectNotAuthorized",
{
@@ -90,7 +67,7 @@ export class EnvironmentConnectNotAuthorized extends Schema.TaggedErrorClass<Env
},
) {
override get message(): string {
return `Environment '${this.environmentId}' is not authorized for ${this.operation}: ${environmentConnectNotAuthorizedReasonMessage(this.reason)}`;
return `Environment '${this.environmentId}' is not authorized for ${this.operation} (${this.reason}).`;
}
}
@@ -28,7 +28,8 @@ describe("ConnectionTransientError.fromStorageFailure", () => {
cause: storageCause,
},
});
expect(error.message).toBe("Could not write local connection data.");
expect(error.detail).toBe("Could not write local connection data.");
expect(error.message).toBe("Connection attempt failed (remote-unavailable).");
});
it("maps a cause-free availability failure without inventing a defect", () => {
@@ -148,27 +148,15 @@ export class ConnectionTransientError extends Schema.TaggedErrorClass<Connection
},
) {
static fromStorageFailure(cause: ConnectionStorageFailure): ConnectionTransientError {
let detail: string;
switch (cause._tag) {
case "ConnectionStorageOperationError":
detail = `Could not ${cause.operation} local connection data.`;
break;
case "IndexedDbUnavailableError":
detail = "IndexedDB is unavailable in this browser context.";
break;
case "DesktopSecureStorageUnavailableError":
detail = "Desktop secure storage is unavailable in this system context.";
break;
}
return new ConnectionTransientError({
reason: "remote-unavailable",
detail,
detail: cause.message,
cause,
});
}
override get message(): string {
return this.detail;
return `Connection attempt failed (${this.reason}).`;
}
}
@@ -185,7 +173,7 @@ export class ConnectionBlockedError extends Schema.TaggedErrorClass<ConnectionBl
},
) {
override get message(): string {
return this.detail;
return `Connection attempt blocked (${this.reason}).`;
}
}
@@ -35,7 +35,7 @@ export function presentConnectionState(
case "connecting":
return {
phase: state.attempt <= 1 && state.lastFailure === null ? "connecting" : "reconnecting",
error: state.lastFailure?.message ?? null,
error: state.lastFailure?.detail ?? null,
traceId: state.lastFailure?.traceId ?? null,
};
case "connected":
@@ -43,13 +43,13 @@ export function presentConnectionState(
case "backoff":
return {
phase: "reconnecting",
error: state.lastFailure?.message ?? null,
error: state.lastFailure?.detail ?? null,
traceId: state.lastFailure?.traceId ?? null,
};
case "blocked":
return {
phase: "error",
error: state.lastFailure?.message ?? null,
error: state.lastFailure?.detail ?? null,
traceId: state.lastFailure?.traceId ?? null,
};
}