fix crash in vercel domain creation flow (#20281)
This commit is contained in:
@@ -2452,7 +2452,6 @@
|
||||
"published": "Published",
|
||||
"unpublished": "Unpublished",
|
||||
"publish": "Publish",
|
||||
"org_publish_error": "Organization could not be published",
|
||||
"troubleshooter_tooltip": "Open the troubleshooter and figure out what is wrong with your schedule",
|
||||
"need_help": "Need help?",
|
||||
"troubleshooter": "Troubleshooter",
|
||||
@@ -3036,6 +3035,7 @@
|
||||
"tip_username_plus": "Tip: You can a '+' between usernames: cal.com/anna+brian to make a dynamic group meeting",
|
||||
"user_has_no_team_yet": "You don't have a team yet",
|
||||
"no_team_members": "You don't have team members yet",
|
||||
"could_not_find_slug_to_publish_org": "Could not find slug to publish the organization",
|
||||
"picklist": "Picklist",
|
||||
"ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS": "↑↑↑↑↑↑↑↑↑↑↑↑↑ Add your new strings above here ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑"
|
||||
}
|
||||
@@ -42,7 +42,7 @@ export function AdminOrgTable() {
|
||||
|
||||
const publishOrg = async (org: (typeof data)[number]) => {
|
||||
if (!org.metadata?.requestedSlug) {
|
||||
showToast(t("org_publish_error"), "error");
|
||||
showToast(t("could_not_find_slug_to_publish_org"), "error");
|
||||
console.error("metadata.requestedSlug isn't set", org.metadata?.requestedSlug);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ const vercelDomainApiResponseSchema = z.object({
|
||||
error: z
|
||||
.object({
|
||||
code: z.string().nullish(),
|
||||
domain: z.string().nullish(),
|
||||
domain: z.any().nullish(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
@@ -28,13 +28,28 @@ export const createDomain = async (domain: string) => {
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
const data = vercelDomainApiResponseSchema.parse(await response.json());
|
||||
const responseJson = await response.json();
|
||||
|
||||
if (!data.error) {
|
||||
const parsedResponse = vercelDomainApiResponseSchema.safeParse(responseJson);
|
||||
|
||||
if (!parsedResponse.success) {
|
||||
// Looks like Vercel changed the response format, so sometimes zod parsing fails
|
||||
log.error(
|
||||
safeStringify({
|
||||
errorMessage: "Failed to parse Vercel domain creation response",
|
||||
zodError: parsedResponse.error,
|
||||
response: responseJson,
|
||||
})
|
||||
);
|
||||
// Let's consider domain creation failed
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parsedResponse.data.error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return handleDomainCreationError(data.error);
|
||||
return handleDomainCreationError(parsedResponse.data.error);
|
||||
};
|
||||
|
||||
export const deleteDomain = async (domain: string) => {
|
||||
|
||||
@@ -34,7 +34,7 @@ export const adminUpdateHandler = async ({ input }: AdminUpdateOptions) => {
|
||||
});
|
||||
}
|
||||
|
||||
const { mergeMetadata } = getMetadataHelpers(teamMetadataSchema.unwrap(), existingOrg.metadata);
|
||||
const { mergeMetadata } = getMetadataHelpers(teamMetadataSchema.unwrap(), existingOrg.metadata || {});
|
||||
|
||||
const data: Prisma.TeamUpdateArgs["data"] = restInput;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user