Skip to content

Commit 0289927

Browse files
committed
fix(jsm): handle 204 No Content on action endpoints and reject array answers
1 parent 47f5ed8 commit 0289927

5 files changed

Lines changed: 9 additions & 5 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ export async function POST(request: NextRequest) {
8383
)
8484
}
8585

86-
const data = await response.json()
86+
const bodyText = await response.text()
87+
const data = bodyText ? JSON.parse(bodyText) : {}
8788

8889
return NextResponse.json({
8990
success: true,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ export async function POST(request: NextRequest) {
8383
)
8484
}
8585

86-
const data = await response.json()
86+
const bodyText = await response.text()
87+
const data = bodyText ? JSON.parse(bodyText) : {}
8788

8889
return NextResponse.json({
8990
success: true,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ export async function POST(request: NextRequest) {
8383
)
8484
}
8585

86-
const data = await response.json()
86+
const bodyText = await response.text()
87+
const data = bodyText ? JSON.parse(bodyText) : {}
8788

8889
return NextResponse.json({
8990
success: true,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function POST(request: NextRequest) {
3939
return NextResponse.json({ error: 'Form ID is required' }, { status: 400 })
4040
}
4141

42-
if (!answers || typeof answers !== 'object') {
42+
if (!answers || typeof answers !== 'object' || Array.isArray(answers)) {
4343
logger.error('Missing or invalid answers in request')
4444
return NextResponse.json({ error: 'Answers object is required' }, { status: 400 })
4545
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ export async function POST(request: NextRequest) {
8383
)
8484
}
8585

86-
const data = await response.json()
86+
const bodyText = await response.text()
87+
const data = bodyText ? JSON.parse(bodyText) : {}
8788

8889
return NextResponse.json({
8990
success: true,

0 commit comments

Comments
 (0)