Skip to content

Commit 86e259d

Browse files
committed
fix(servicenow): drop redundant hidden fileContent param from upload attachment
Per project rule, visibility:'hidden' is reserved for framework-injected tokens, not user-supplied data. fileContent was a copied-over legacy fallback with no caller (the block uploads via the canonical file/UserFile path), so remove it from the tool, types, contract, and route.
1 parent ff42c41 commit 86e259d

4 files changed

Lines changed: 14 additions & 31 deletions

File tree

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

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,34 +35,26 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
3535
if (!parsed.success) return parsed.response
3636
const body = parsed.data.body
3737

38-
let fileBuffer: Buffer
39-
let contentType = 'application/octet-stream'
40-
41-
if (body.file) {
42-
let userFile
43-
try {
44-
userFile = processSingleFileToUserFile(body.file, requestId, logger)
45-
} catch (error) {
46-
return NextResponse.json(
47-
{ success: false, error: getErrorMessage(error, 'Failed to process file') },
48-
{ status: 400 }
49-
)
50-
}
51-
52-
const denied = await assertToolFileAccess(userFile.key, authResult.userId, requestId, logger)
53-
if (denied) return denied
38+
if (!body.file) {
39+
return NextResponse.json({ success: false, error: 'A file is required' }, { status: 400 })
40+
}
5441

55-
if (userFile.type) contentType = userFile.type
56-
fileBuffer = await downloadFileFromStorage(userFile, requestId, logger)
57-
} else if (body.fileContent) {
58-
fileBuffer = Buffer.from(body.fileContent, 'base64')
59-
} else {
42+
let userFile
43+
try {
44+
userFile = processSingleFileToUserFile(body.file, requestId, logger)
45+
} catch (error) {
6046
return NextResponse.json(
61-
{ success: false, error: 'Either file or fileContent must be provided' },
47+
{ success: false, error: getErrorMessage(error, 'Failed to process file') },
6248
{ status: 400 }
6349
)
6450
}
6551

52+
const denied = await assertToolFileAccess(userFile.key, authResult.userId, requestId, logger)
53+
if (denied) return denied
54+
55+
const contentType = userFile.type || 'application/octet-stream'
56+
const fileBuffer = await downloadFileFromStorage(userFile, requestId, logger)
57+
6658
const baseUrl = body.instanceUrl.trim().replace(/\/$/, '')
6759
const uploadParams = new URLSearchParams({
6860
table_name: body.tableName.trim(),

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export const servicenowUploadAttachmentBodySchema = z.object({
1010
recordSysId: z.string().min(1, 'Record sys_id is required'),
1111
fileName: z.string().min(1, 'File name is required'),
1212
file: RawFileInputSchema.optional().nullable(),
13-
fileContent: z.string().optional().nullable(),
1413
})
1514

1615
export type ServiceNowUploadAttachmentBody = z.input<typeof servicenowUploadAttachmentBodySchema>

apps/sim/tools/servicenow/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ export interface ServiceNowUploadAttachmentParams {
152152
recordSysId: string
153153
fileName: string
154154
file?: unknown
155-
fileContent?: string
156155
}
157156

158157
export interface ServiceNowUploadAttachmentResponse extends ToolResponse {

apps/sim/tools/servicenow/upload_attachment.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ export const uploadAttachmentTool: ToolConfig<
5959
visibility: 'user-only',
6060
description: 'File to upload (UserFile object)',
6161
},
62-
fileContent: {
63-
type: 'string',
64-
required: false,
65-
visibility: 'hidden',
66-
description: 'Base64-encoded file content (legacy)',
67-
},
6862
},
6963

7064
request: {
@@ -81,7 +75,6 @@ export const uploadAttachmentTool: ToolConfig<
8175
recordSysId: params.recordSysId,
8276
fileName: params.fileName,
8377
file: params.file,
84-
fileContent: params.fileContent,
8578
}),
8679
},
8780

0 commit comments

Comments
 (0)