Skip to content

Commit 0421404

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(quickbooks): align file response limits
1 parent 87e353e commit 0421404

4 files changed

Lines changed: 20 additions & 0 deletions

File tree

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ import { QuickBooksBlock } from '@/blocks/blocks/quickbooks'
44
import {
55
getQuickBooksAttachmentTarget,
66
parseQuickBooksAttachableResponse,
7+
QUICKBOOKS_FILE_TOOL_RESPONSE_MAX_BYTES,
78
sanitizeQuickBooksFileName,
89
validateQuickBooksAttachmentFileType,
910
} from '@/tools/quickbooks/documents_utils'
11+
import { quickbooksDownloadAttachmentTool } from '@/tools/quickbooks/download_attachment'
12+
import { quickbooksDownloadTransactionPdfTool } from '@/tools/quickbooks/download_transaction_pdf'
1013
import { quickbooksEmailTransactionTool } from '@/tools/quickbooks/email_transaction'
1114
import { quickbooksReadAttachmentsTool } from '@/tools/quickbooks/read_attachments'
1215
import type {
@@ -251,6 +254,16 @@ describe('QuickBooks document validation and block parity', () => {
251254
)
252255
})
253256

257+
it('allows bounded 100 MiB file outputs to pass through the tool executor', () => {
258+
expect(quickbooksDownloadTransactionPdfTool.request.maxResponseBytes).toBe(
259+
QUICKBOOKS_FILE_TOOL_RESPONSE_MAX_BYTES
260+
)
261+
expect(quickbooksDownloadAttachmentTool.request.maxResponseBytes).toBe(
262+
QUICKBOOKS_FILE_TOOL_RESPONSE_MAX_BYTES
263+
)
264+
expect(QUICKBOOKS_FILE_TOOL_RESPONSE_MAX_BYTES).toBeGreaterThan((100 * 1024 * 1024 * 4) / 3)
265+
})
266+
254267
it('exposes exactly 45 operation/tool pairs and a canonical single-file input pair', () => {
255268
const operation = QuickBooksBlock.subBlocks.find((block) => block.id === 'operation')
256269
expect(operation?.options).toHaveLength(45)

apps/sim/tools/quickbooks/documents_utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { readResponseTextWithLimit } from '@/lib/core/utils/stream-limits'
22
import type { RawFileInput } from '@/lib/uploads/utils/file-schemas'
3+
import { MAX_FILE_SIZE } from '@/lib/uploads/utils/validation'
34
import { QUICKBOOKS_MAX_RESPONSE_BYTES } from '@/tools/quickbooks/client'
45
import { formatQuickBooksFaultDetail, sanitizeQuickBooksFaultData } from '@/tools/quickbooks/fault'
56
import type {
@@ -173,6 +174,8 @@ export function assertSingleQuickBooksFile(file: RawFileInput | undefined): RawF
173174

174175
export const QUICKBOOKS_TEMP_URL_MAX_BYTES = 64 * 1024
175176
export const QUICKBOOKS_DOCUMENT_JSON_MAX_BYTES = QUICKBOOKS_MAX_RESPONSE_BYTES
177+
export const QUICKBOOKS_FILE_TOOL_RESPONSE_MAX_BYTES =
178+
Math.ceil((MAX_FILE_SIZE * 4) / 3) + 256 * 1024
176179

177180
export async function getQuickBooksDocumentError(response: Response): Promise<Error> {
178181
let detail = ''

apps/sim/tools/quickbooks/download_attachment.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { QUICKBOOKS_FILE_TOOL_RESPONSE_MAX_BYTES } from '@/tools/quickbooks/documents_utils'
12
import type {
23
QuickBooksDownloadAttachmentParams,
34
QuickBooksFileResponse,
@@ -49,6 +50,7 @@ export const quickbooksDownloadAttachmentTool: ToolConfig<
4950
method: 'POST',
5051
headers: () => ({ 'Content-Type': 'application/json' }),
5152
body: (params) => params,
53+
maxResponseBytes: QUICKBOOKS_FILE_TOOL_RESPONSE_MAX_BYTES,
5254
},
5355
outputs: {
5456
...QUICKBOOKS_FILE_OUTPUTS,

apps/sim/tools/quickbooks/download_transaction_pdf.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { QUICKBOOKS_FILE_TOOL_RESPONSE_MAX_BYTES } from '@/tools/quickbooks/documents_utils'
12
import type {
23
QuickBooksDownloadTransactionPdfParams,
34
QuickBooksFileResponse,
@@ -55,6 +56,7 @@ export const quickbooksDownloadTransactionPdfTool: ToolConfig<
5556
method: 'POST',
5657
headers: () => ({ 'Content-Type': 'application/json' }),
5758
body: (params) => params,
59+
maxResponseBytes: QUICKBOOKS_FILE_TOOL_RESPONSE_MAX_BYTES,
5860
},
5961
outputs: {
6062
...QUICKBOOKS_FILE_OUTPUTS,

0 commit comments

Comments
 (0)