File tree Expand file tree Collapse file tree 4 files changed +35
-9
lines changed
Expand file tree Collapse file tree 4 files changed +35
-9
lines changed Original file line number Diff line number Diff line change @@ -66,10 +66,18 @@ export const createRecordTool: ToolConfig<
6666 name : params . name ,
6767 }
6868 if ( params . properties ) {
69- body . properties = JSON . parse ( params . properties )
69+ try {
70+ body . properties = JSON . parse ( params . properties )
71+ } catch {
72+ throw new Error ( 'Invalid JSON in properties field' )
73+ }
7074 }
7175 if ( params . links ) {
72- body . links = JSON . parse ( params . links )
76+ try {
77+ body . links = JSON . parse ( params . links )
78+ } catch {
79+ throw new Error ( 'Invalid JSON in links field' )
80+ }
7381 }
7482 return body
7583 } ,
Original file line number Diff line number Diff line change @@ -52,7 +52,11 @@ export const createWorkflowTool: ToolConfig<
5252 template : params . template ,
5353 }
5454 if ( params . attributes ) {
55- body . attributes = JSON . parse ( params . attributes )
55+ try {
56+ body . attributes = JSON . parse ( params . attributes )
57+ } catch {
58+ throw new Error ( 'Invalid JSON in attributes field' )
59+ }
5660 }
5761 return body
5862 } ,
Original file line number Diff line number Diff line change @@ -47,7 +47,13 @@ export const updateRecordTool: ToolConfig<
4747 'Content-Type' : 'application/json' ,
4848 Accept : 'application/json' ,
4949 } ) ,
50- body : ( params ) => JSON . parse ( params . properties ) ,
50+ body : ( params ) => {
51+ try {
52+ return JSON . parse ( params . properties )
53+ } catch {
54+ throw new Error ( 'Invalid JSON in properties field' )
55+ }
56+ } ,
5157 } ,
5258
5359 transformResponse : async ( response : Response ) => {
Original file line number Diff line number Diff line change @@ -50,15 +50,23 @@ export const updateWorkflowMetadataTool: ToolConfig<
5050 'Content-Type' : 'application/json' ,
5151 Accept : 'application/json' ,
5252 } ) ,
53- body : ( params ) => ( {
54- actions : JSON . parse ( params . actions ) ,
55- } ) ,
53+ body : ( params ) => {
54+ try {
55+ return { actions : JSON . parse ( params . actions ) }
56+ } catch {
57+ throw new Error ( 'Invalid JSON in actions field' )
58+ }
59+ } ,
5660 } ,
5761
5862 transformResponse : async ( response : Response ) => {
5963 if ( ! response . ok ) {
60- const data = await response . json ( )
61- throw new Error ( data . message || data . error || 'Failed to update workflow metadata' )
64+ const data = await response . json ( ) . catch ( ( ) => ( { } ) )
65+ throw new Error (
66+ ( data as Record < string , string > ) . message ||
67+ ( data as Record < string , string > ) . error ||
68+ 'Failed to update workflow metadata'
69+ )
6270 }
6371
6472 return {
You can’t perform that action at this time.
0 commit comments