diff --git a/packages/lib/domainManager/deploymentServices/vercel.ts b/packages/lib/domainManager/deploymentServices/vercel.ts index 46d295be86..27ff4b1311 100644 --- a/packages/lib/domainManager/deploymentServices/vercel.ts +++ b/packages/lib/domainManager/deploymentServices/vercel.ts @@ -12,6 +12,8 @@ const vercelDomainApiResponseSchema = z.object({ .object({ code: z.string().nullish(), domain: z.any().nullish(), + message: z.string().nullish(), + invalidToken: z.boolean().nullish(), }) .optional(), }); @@ -74,10 +76,16 @@ export const deleteDomain = async (domain: string) => { return handleDomainDeletionError(data.error); }; -function handleDomainCreationError(error: { code?: string | null; domain?: string | null }) { - // Domain is already owned by another team but you can request delegation to access it +function handleDomainCreationError(error: { + code?: string | null; + domain?: string | null; + message?: string | null; + invalidToken?: boolean | null; +}){ + // Vercel returns "forbidden" for various permission issues, not just domain ownership if (error.code === "forbidden") { - const errorMessage = "Domain is already owned by another team"; + const errorMessage = + "Vercel denied permission to manage this domain. Please verify your Vercel project, team, and domain permissions."; log.error( safeStringify({ errorMessage, @@ -117,15 +125,21 @@ function handleDomainCreationError(error: { code?: string | null; domain?: strin }); } -function handleDomainDeletionError(error: { code?: string | null; domain?: string | null }) { +function handleDomainDeletionError(error: { + code?: string | null; + domain?: string | null; + message?: string | null; + invalidToken?: boolean | null; +}){ if (error.code === "not_found") { // Domain is already deleted return true; } - // Domain is already owned by another team but you can request delegation to access it + // Vercel returns "forbidden" for various permission issues, not just domain ownership if (error.code === "forbidden") { - const errorMessage = "Domain is owned by another team"; + const errorMessage = + "Vercel denied permission to manage this domain. Please verify your Vercel project, team, and domain permissions."; log.error( safeStringify({ errorMessage,