diff --git a/apps/sim/tools/jsm/utils.ts b/apps/sim/tools/jsm/utils.ts index 0081547258..ed333a5a73 100644 --- a/apps/sim/tools/jsm/utils.ts +++ b/apps/sim/tools/jsm/utils.ts @@ -50,13 +50,29 @@ export function parseJsmErrorMessage( ): string { try { const errorData = JSON.parse(errorText) + // JSM Service Desk: singular errorMessage if (errorData.errorMessage) { - return `JSM Forms API error: ${errorData.errorMessage}` + return errorData.errorMessage + } + // Jira Platform: errorMessages array + if (Array.isArray(errorData.errorMessages) && errorData.errorMessages.length > 0) { + return errorData.errorMessages.join(', ') + } + // Confluence v2 / Forms API: RFC 7807 errors array + if (Array.isArray(errorData.errors) && errorData.errors.length > 0) { + const err = errorData.errors[0] + if (err?.title) { + return err.detail ? `${err.title}: ${err.detail}` : err.title + } + } + // Generic message fallback + if (errorData.message) { + return errorData.message } } catch { if (errorText) { - return `JSM Forms API error: ${errorText}` + return errorText } } - return `JSM Forms API error: ${status} ${statusText}` + return `${status} ${statusText}` }