Skip to content

Commit 252a0e1

Browse files
committed
add check when attachment size exceeds
1 parent da136da commit 252a0e1

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

packages/backend/src/apps/postman/common/data-out-validator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const dataOutSchema = z.object(
88
'BLACKLISTED',
99
'RATE-LIMITED',
1010
'INVALID-ATTACHMENT',
11+
'ATTACHMENT-SIZE-EXCEEDED',
1112
'INTERMITTENT-ERROR',
1213
'ERROR',
1314
]),

packages/backend/src/apps/postman/common/email-helper.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,16 @@ export async function sendTransactionalEmails(
159159
* Since we can only return one error per postman step, we have to select in terms of priority
160160
* 1. RATE-LIMITED (so we can auto-retry)
161161
* 2. INVALID-ATTACHMENT (probably all recipients should fail)
162-
* 3. INTERMITTENT-ERROR (some recipients failed, auto-retry)
163-
* 4. ERROR (probably all recipients should fail)
164-
* 5. BLACKLISTED (blacklisted errors are returned even if there are other errors like invalid attachment)
162+
* 3. ATTACHMENT-SIZE-EXCEEDED (probably all recipients should fail)
163+
* 4. INTERMITTENT-ERROR (some recipients failed, auto-retry)
164+
* 5. ERROR (probably all recipients should fail)
165+
* 6. BLACKLISTED (blacklisted errors are returned even if there are other errors like invalid attachment)
165166
*/
166167
const sortedErrors = sortBy(errors, (error) =>
167168
[
168169
'RATE-LIMITED',
169170
'INVALID-ATTACHMENT',
171+
'ATTACHMENT-SIZE-EXCEEDED',
170172
'INTERMITTENT-ERROR',
171173
'ERROR',
172174
'BLACKLISTED',

packages/backend/src/apps/postman/common/throw-errors.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export function getPostmanErrorStatus(
3636
}
3737
case 'rate_limit':
3838
return 'RATE-LIMITED'
39+
case 'attachment_limit':
40+
return 'ATTACHMENT-SIZE-EXCEEDED'
3941
default:
4042
if (POSTMAN_RETRIABLE_HTTP_CODES.includes(error.response?.status)) {
4143
return 'INTERMITTENT-ERROR'
@@ -105,6 +107,14 @@ export function throwPostmanStepError({
105107
appName,
106108
error,
107109
)
110+
case 'ATTACHMENT-SIZE-EXCEEDED':
111+
throw new StepError(
112+
'Total attachment size exceeded',
113+
'Click on set up action and check that the attachments do not exceed 10MB in total.',
114+
position,
115+
appName,
116+
error,
117+
)
108118
case 'INTERMITTENT-ERROR':
109119
throw new RetriableError({
110120
error: error.details,

0 commit comments

Comments
 (0)