File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -86,18 +86,20 @@ export async function setConfigValue(args: unknown) {
8686 if ( ( parsed . data . key === 'allowedDirectories' || parsed . data . key === 'blockedCommands' ) &&
8787 ! Array . isArray ( valueToStore ) ) {
8888 if ( typeof valueToStore === 'string' ) {
89+ const originalString = valueToStore ;
8990 try {
90- valueToStore = JSON . parse ( valueToStore ) ;
91+ const parsedValue = JSON . parse ( originalString ) ;
92+ valueToStore = parsedValue ;
9193 } catch ( parseError ) {
9294 console . error ( `Failed to parse string as array for ${ parsed . data . key } : ${ parseError } ` ) ;
9395 // If parsing failed and it's a single value, convert to an array with one item
94- if ( ! valueToStore . includes ( '[' ) ) {
95- valueToStore = [ valueToStore ] ;
96+ if ( ! originalString . includes ( '[' ) ) {
97+ valueToStore = [ originalString ] ;
9698 }
9799 }
98- } else {
99- // If not a string or array, convert to an array with one item
100- valueToStore = [ valueToStore ] ;
100+ } else if ( valueToStore !== null ) {
101+ // If not a string or array (and not null) , convert to an array with one item
102+ valueToStore = [ String ( valueToStore ) ] ;
101103 }
102104
103105 // Ensure the value is an array after all our conversions
Original file line number Diff line number Diff line change @@ -5,7 +5,13 @@ export const GetConfigArgsSchema = z.object({});
55
66export const SetConfigValueArgsSchema = z . object ( {
77 key : z . string ( ) ,
8- value : z . any ( ) ,
8+ value : z . union ( [
9+ z . string ( ) ,
10+ z . number ( ) ,
11+ z . boolean ( ) ,
12+ z . array ( z . string ( ) ) ,
13+ z . null ( ) ,
14+ ] ) ,
915} ) ;
1016
1117// Empty schemas
You can’t perform that action at this time.
0 commit comments