Skip to content

Commit b500a0e

Browse files
committed
fix(mailchimp): reject tag statuses other than active and inactive
1 parent c17048c commit b500a0e

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎apps/sim/tools/mailchimp/mailchimp.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ describe('Mailchimp request bodies', () => {
101101
bodyOf(mailchimpAddMemberTagsTool, { ...params, tags: '[{"name":"VIP"}' })
102102
).toThrow()
103103
expect(() => bodyOf(mailchimpAddMemberTagsTool, { ...params, tags: '[]' })).toThrow()
104+
expect(() =>
105+
bodyOf(mailchimpAddMemberTagsTool, { ...params, tags: '[{"name":"VIP","status":"paused"}]' })
106+
).toThrow()
104107
})
105108

106109
it('accepts an already-parsed operations array and rejects unparseable operations', () => {

‎apps/sim/tools/mailchimp/types.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,10 @@ export function buildMemberTags(
420420
const name =
421421
typeof tag.name === 'string' || typeof tag.name === 'number' ? String(tag.name).trim() : ''
422422
if (!name) return []
423-
const status = typeof tag.status === 'string' && tag.status ? tag.status : defaultStatus
423+
const status = tag.status === undefined || tag.status === '' ? defaultStatus : tag.status
424+
if (status !== 'active' && status !== 'inactive') {
425+
throw new Error(`Tag status must be "active" or "inactive", got ${JSON.stringify(status)}`)
426+
}
424427
return [{ name, status }]
425428
}
426429
return []

0 commit comments

Comments
 (0)