2
0

fix: 🐛 Misc

This commit is contained in:
Baptiste Arnaud
2022-05-12 07:04:43 -07:00
parent 9213dd33fe
commit 092f16d3c1
4 changed files with 13 additions and 5 deletions

View File

@ -142,11 +142,11 @@ export const executeWebhook =
...basicAuth,
json:
contentType !== 'x-www-form-urlencoded' && body
? JSON.parse(parseVariables(variables)(body))
? safeJsonParse(parseVariables(variables)(body))
: undefined,
form:
contentType === 'x-www-form-urlencoded' && body
? JSON.parse(parseVariables(variables)(body))
? safeJsonParse(parseVariables(variables)(body))
: undefined,
}
try {
@ -240,4 +240,12 @@ const convertKeyValueTableToObject = (
}, {})
}
const safeJsonParse = (json: string): any => {
try {
return JSON.parse(json)
} catch (err) {
return json
}
}
export default withSentry(handler)

View File

@ -37,7 +37,7 @@ const saveLog = (
message: string,
details?: any
) => {
if (!resultId) return
if (!resultId || resultId === 'undefined') return
return prisma.log.create({
data: {
resultId,

View File

@ -105,7 +105,7 @@ const getSampleValue = (step: InputStep) => {
case InputStepType.CHOICE:
return step.options.isMultipleChoice
? step.items.map((i) => i.content).join(', ')
: step.items[0].content ?? 'Item'
: step.items[0]?.content ?? 'Item'
case InputStepType.DATE:
return new Date().toUTCString()
case InputStepType.EMAIL:

View File

@ -1,4 +1,4 @@
import { Log, Result } from 'db'
import { Result } from 'db'
import { sendRequest } from 'utils'
export const createResult = async (typebotId: string) => {