Skip to content

Commit 5f8f819

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(quickbooks): omit null optional values
1 parent 21de012 commit 5f8f819

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

apps/sim/blocks/blocks/quickbooks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ function parseTriStateBoolean(value: unknown, fieldName: string): boolean | unde
6868
}
6969

7070
function optionalValue(value: unknown): unknown {
71+
if (value == null) return undefined
7172
return typeof value === 'string' && value.trim() === '' ? undefined : value
7273
}
7374

apps/sim/tools/quickbooks/quickbooks.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,25 @@ describe('QuickBooks tool and block boundaries', () => {
824824
})
825825
})
826826

827+
it('omits optional values serialized as null by the editor', () => {
828+
const params = QuickBooksBlock.tools.config!.params!({
829+
operation: 'quickbooks_create_customer',
830+
oauthCredential: 'credential-id',
831+
displayName: 'Sanitized Customer',
832+
companyName: null,
833+
primaryEmail: null,
834+
primaryPhone: '',
835+
})
836+
837+
expect(params).toMatchObject({
838+
credential: 'credential-id',
839+
displayName: 'Sanitized Customer',
840+
})
841+
expect(params.companyName).toBeUndefined()
842+
expect(params.primaryEmail).toBeUndefined()
843+
expect(params.primaryPhone).toBeUndefined()
844+
})
845+
827846
it('omits unrelated coercion for CompanyInfo and rejects bad operation values', () => {
828847
expect(
829848
QuickBooksBlock.tools.config!.params!({

0 commit comments

Comments
 (0)