Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

Improve pool name conflict message (#7325)

r33drichards9fceeccd84c1
diff --git a/libs/fleet/src/error-message.ts b/libs/fleet/src/error-message.ts
index 75c3f5f785..34c1e5ffa2 100644
--- a/libs/fleet/src/error-message.ts
+++ b/libs/fleet/src/error-message.ts
@@ -41,6 +41,17 @@ function uniffiErrorDetail(error: UniffiErrorLike): string | undefined {
return undefined
}
+export function poolCreateErrorMessage(error: unknown, poolName: string): string {
+ if (
+ error &&
+ typeof error === "object" &&
+ (error as UniffiErrorLike).tag === "PoolAccessDenied"
+ ) {
+ return `Pool names must be globally unique across all accounts, similar to DNS names. "${poolName}" may already be in use. Try a different name.`
+ }
+ return errorMessage(error)
+}
+
export function errorMessage(error: unknown): string {
if (error && typeof error === "object") {
const detail = uniffiErrorDetail(error as UniffiErrorLike)
diff --git a/libs/fleet/src/pages/PoolNew.tsx b/libs/fleet/src/pages/PoolNew.tsx
index 7394fd6f07..681144472a 100644
--- a/libs/fleet/src/pages/PoolNew.tsx
+++ b/libs/fleet/src/pages/PoolNew.tsx
@@ -17,7 +17,7 @@ import { recordFleetPaymentGate, type FleetPaymentGateReason } from "../auth/ana
import { kc } from "../auth/keycloak"
import { useFeatureFlags } from "../components/FeatureFlagContext"
import { useFlash } from "../components/FlashContext"
-import { errorMessage } from "../error-message"
+import { poolCreateErrorMessage } from "../error-message"
import { createPool } from "../fleet/pools"
import type { PoolTemplateConfig } from "../fleet/models"
import { CuaButton } from "../components/CuaButton"
@@ -262,7 +262,7 @@ export function PoolNew() {
flash.push({
type: "error",
header: "Create failed",
- content: errorMessage(e),
+ content: poolCreateErrorMessage(e, name),
})
} finally {
setSubmitting(false)
diff --git a/libs/fleet/tests/error-message.test.ts b/libs/fleet/tests/error-message.test.ts
index 84477f11a6..a880689a12 100644
--- a/libs/fleet/tests/error-message.test.ts
+++ b/libs/fleet/tests/error-message.test.ts
@@ -1,6 +1,9 @@
import assert from "node:assert/strict"
import test from "node:test"
-import { errorMessage } from "../src/error-message.ts"
+import {
+ errorMessage,
+ poolCreateErrorMessage,
+} from "../src/error-message.ts"
// Structural stand-ins for uniffi enum errors (e.g. the fleet SDK's
// SdkError): a real one is an Error whose message is just the variant name
@@ -68,6 +71,27 @@ test("handles PoolAccessDenied's {status, body} payload like Status", () => {
assert.equal(errorMessage(error), "namespace demo is not yours")
})
+test("explains that pool names are globally unique on create access denial", () => {
+ const error = uniffiError("PoolAccessDenied", {
+ operation: "create pool",
+ namespace: "demo",
+ status: 403,
+ body:
+ 'osgymsandboxwarmpools.osgym.cua.ai is forbidden: cannot create resource "osgymsandboxwarmpools"',
+ })
+ assert.equal(
+ poolCreateErrorMessage(error, "demo"),
+ 'Pool names must be globally unique across all accounts, similar to DNS names. "demo" may already be in use. Try a different name.',
+ )
+})
+
+test("keeps unrelated pool create errors unchanged", () => {
+ assert.equal(
+ poolCreateErrorMessage(new Error("upstream unavailable"), "demo"),
+ "upstream unavailable",
+ )
+})
+
test("surfaces reason-only variants like Transport", () => {
const error = uniffiError("Transport", { reason: "dns lookup failed" })
assert.equal(errorMessage(error), "dns lookup failed")