Skip to content

Commit 20e65a6

Browse files
committed
fix(zoho-desk): only add the edition hint when Zoho's error indicates it
mapZohoWebhookError appended the "requires Professional edition or higher" guidance to every 403, but a 403 can also mean a wrong org, a missing scope, or a bad token. Gate the hint on Zoho's own errorCode / message matching the permission/edition pattern instead of the bare status, so unrelated 403s surface Zoho's real reason without the misleading suffix. Adds a test for the non-edition 403 path.
1 parent 210aadc commit 20e65a6

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

apps/sim/lib/webhooks/providers/zoho-desk.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,17 @@ describe('zohoDeskHandler', () => {
255255
expect(errorStatus(err)).toBe(403)
256256
})
257257

258+
it('does not add the edition hint to a 403 whose body is unrelated to edition/permission', () => {
259+
const err = mapZohoWebhookError(
260+
403,
261+
JSON.stringify({ errorCode: 'INVALID_OAUTH', message: 'Invalid OAuth token' })
262+
)
263+
expect(err.message).toContain('INVALID_OAUTH')
264+
expect(err.message).toContain('Invalid OAuth token')
265+
expect(err.message).not.toContain('Professional edition')
266+
expect(errorStatus(err)).toBe(403)
267+
})
268+
258269
it('keeps provider 5xx retryable', () => {
259270
const err = mapZohoWebhookError(500, JSON.stringify({ errorCode: 'INTERNAL_ERROR' }))
260271
expect(errorStatus(err)).toBe(503)

apps/sim/lib/webhooks/providers/zoho-desk.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ export function mapZohoWebhookError(status: number, bodyText: string): Error {
121121
const codePrefix = errorCode ? `${errorCode}: ` : ''
122122
let realMessage = `Zoho Desk webhook creation failed (HTTP ${status}) - ${codePrefix}${detail}`
123123

124-
// Only claim the edition/permission cause when Zoho's response actually says so.
124+
// Only claim the edition/permission cause when Zoho's own errorCode or message
125+
// says so. A bare 403 can equally mean a wrong org, a missing scope, or a bad
126+
// token, and those must not get the misleading "requires Professional" suffix.
125127
const indicatesEditionOrPermission =
126-
status === 403 ||
127128
(errorCode ? ZOHO_EDITION_PERMISSION_PATTERN.test(errorCode) : false) ||
128129
ZOHO_EDITION_PERMISSION_PATTERN.test(detail)
129130
if (indicatesEditionOrPermission) {

0 commit comments

Comments
 (0)