Skip to content

Commit c0baea8

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(quickbooks): normalize upload minor version
1 parent 442cb3f commit c0baea8

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

apps/sim/app/api/tools/quickbooks/upload-attachment/route.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,21 @@ describe('POST /api/tools/quickbooks/upload-attachment', () => {
135135
)
136136
})
137137

138+
it('defaults a blank minor version instead of rejecting the upload', async () => {
139+
const response = await POST(
140+
createMockRequest('POST', {
141+
...baseBody,
142+
minorVersion: ' ',
143+
})
144+
)
145+
146+
expect(response.status).toBe(200)
147+
expect(mockFetch).toHaveBeenCalledWith(
148+
'https://quickbooks.api.intuit.com/v3/company/123145/upload?minorversion=75',
149+
expect.any(Object)
150+
)
151+
})
152+
138153
it('normalizes linked entity names before building attachment metadata', async () => {
139154
const response = await POST(
140155
createMockRequest('POST', {

apps/sim/lib/api/contracts/tools/quickbooks.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,17 @@ export const quickBooksUploadAttachmentBodySchema = z.object({
2727
note: z.string().max(2000, 'Attachment note must be 2000 characters or less').optional(),
2828
includeOnSend: z.boolean().optional(),
2929
apiEnvironment: z.enum(['production', 'sandbox']).optional(),
30-
minorVersion: z
31-
.string()
32-
.regex(/^\d{1,5}$/, 'Minor version must contain one to five digits')
33-
.optional(),
30+
minorVersion: z.preprocess(
31+
(value) => {
32+
if (typeof value !== 'string') return value
33+
const trimmed = value.trim()
34+
return trimmed || undefined
35+
},
36+
z
37+
.string()
38+
.regex(/^\d{1,5}$/, 'Minor version must contain one to five digits')
39+
.optional()
40+
),
3441
})
3542

3643
const quickBooksUploadAttachmentResponseSchema = z.union([

0 commit comments

Comments
 (0)