Skip to content

Commit 37152fd

Browse files
committed
fix(jsm): validate formIds is an array in copy_forms route and block
1 parent 0289927 commit 37152fd

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

apps/sim/app/api/tools/jsm/forms/copy/route.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ export async function POST(request: NextRequest) {
6666
const baseUrl = getJsmFormsApiBaseUrl(cloudId)
6767
const url = `${baseUrl}/issue/${encodeURIComponent(sourceIssueIdOrKey)}/form/copy/${encodeURIComponent(targetIssueIdOrKey)}`
6868

69+
if (formIds !== undefined && !Array.isArray(formIds)) {
70+
return NextResponse.json({ error: 'formIds must be an array of form UUIDs' }, { status: 400 })
71+
}
72+
6973
const requestBody = Array.isArray(formIds) && formIds.length > 0 ? { ids: formIds } : {}
7074

7175
logger.info('Copying forms:', { url, sourceIssueIdOrKey, targetIssueIdOrKey, formIds })

apps/sim/blocks/blocks/jira_service_management.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,9 +1092,15 @@ Return ONLY the comment text - no explanations.`,
10921092
formIds: params.formIds
10931093
? (() => {
10941094
try {
1095-
return JSON.parse(params.formIds)
1096-
} catch {
1097-
throw new Error('formIds must be valid JSON array')
1095+
const parsed = JSON.parse(params.formIds)
1096+
if (!Array.isArray(parsed)) {
1097+
throw new Error('formIds must be a JSON array')
1098+
}
1099+
return parsed
1100+
} catch (e) {
1101+
throw e instanceof Error && e.message === 'formIds must be a JSON array'
1102+
? e
1103+
: new Error('formIds must be valid JSON array')
10981104
}
10991105
})()
11001106
: undefined,

0 commit comments

Comments
 (0)