Skip to content

Commit b80c069

Browse files
fix: improve Vercel domain 'forbidden' error message and add schema fields (calcom#25520)
* fix: improve Vercel domain 'forbidden' error message The 'forbidden' error code from Vercel is a generic permission denial, not specifically 'domain owned by another team'. It can occur for various reasons: wrong teamId, token lacking project access, account-level restrictions, or domain ownership by another team. Updated the error message to be more accurate and changed the HTTP status code from 400 to 403 to better reflect the permission error nature. Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * fix: add message and invalidToken fields to Vercel error response schema This allows better logging of Vercel API error responses, especially when tokens become invalid. The new fields help with debugging permission issues. Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * fix: revert status code to 400 for Vercel forbidden errors Keep the status code at 400 to avoid potential downstream side effects while still using the improved error message and schema fields. Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * fix: use .nullish() instead of .optional() for message and invalidToken fields .nullish() handles both null and undefined, which is safer for API responses. Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 44291be commit b80c069

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

  • packages/lib/domainManager/deploymentServices

packages/lib/domainManager/deploymentServices/vercel.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const vercelDomainApiResponseSchema = z.object({
1212
.object({
1313
code: z.string().nullish(),
1414
domain: z.any().nullish(),
15+
message: z.string().nullish(),
16+
invalidToken: z.boolean().nullish(),
1517
})
1618
.optional(),
1719
});
@@ -74,10 +76,16 @@ export const deleteDomain = async (domain: string) => {
7476
return handleDomainDeletionError(data.error);
7577
};
7678

77-
function handleDomainCreationError(error: { code?: string | null; domain?: string | null }) {
78-
// Domain is already owned by another team but you can request delegation to access it
79+
function handleDomainCreationError(error: {
80+
code?: string | null;
81+
domain?: string | null;
82+
message?: string | null;
83+
invalidToken?: boolean | null;
84+
}){
85+
// Vercel returns "forbidden" for various permission issues, not just domain ownership
7986
if (error.code === "forbidden") {
80-
const errorMessage = "Domain is already owned by another team";
87+
const errorMessage =
88+
"Vercel denied permission to manage this domain. Please verify your Vercel project, team, and domain permissions.";
8189
log.error(
8290
safeStringify({
8391
errorMessage,
@@ -117,15 +125,21 @@ function handleDomainCreationError(error: { code?: string | null; domain?: strin
117125
});
118126
}
119127

120-
function handleDomainDeletionError(error: { code?: string | null; domain?: string | null }) {
128+
function handleDomainDeletionError(error: {
129+
code?: string | null;
130+
domain?: string | null;
131+
message?: string | null;
132+
invalidToken?: boolean | null;
133+
}){
121134
if (error.code === "not_found") {
122135
// Domain is already deleted
123136
return true;
124137
}
125138

126-
// Domain is already owned by another team but you can request delegation to access it
139+
// Vercel returns "forbidden" for various permission issues, not just domain ownership
127140
if (error.code === "forbidden") {
128-
const errorMessage = "Domain is owned by another team";
141+
const errorMessage =
142+
"Vercel denied permission to manage this domain. Please verify your Vercel project, team, and domain permissions.";
129143
log.error(
130144
safeStringify({
131145
errorMessage,

0 commit comments

Comments
 (0)