@@ -325,8 +325,25 @@ AgentClient.prototype = {
325325 // These functions should be used when working with the task/proc API.
326326 //
327327
328+ _clean_params : function ( params ) {
329+ // Before passing params to a task/process start method, strip off
330+ // any entries that have value = null.
331+ //
332+ // It is almost always the case that passing a param value of None
333+ // (null) has the same effect as not passing the param at all.
334+ // Unless a param is defined with "treat_none_as_missing=False",
335+ // that will be the case. So to minimize compatibility problems
336+ // due to new (but empty) parameters in ocs-web conflicting with
337+ // older agents, we strip off any params with null values.
338+ return Object . entries ( params ) . reduce ( ( acc , [ key , value ] ) => {
339+ if ( value !== null )
340+ acc [ key ] = value ;
341+ return acc ;
342+ } , { } ) ;
343+ } ,
344+
328345 start_task : function ( task_name , params ) {
329- return this . dispatch ( 'start' , task_name , params ) ;
346+ return this . dispatch ( 'start' , task_name , this . _clean_params ( params ) ) ;
330347 } ,
331348
332349 wait_task : function ( task_name , params ) {
@@ -368,7 +385,7 @@ AgentClient.prototype = {
368385 } ,
369386
370387 start_proc : function ( proc_name , params ) {
371- return this . dispatch ( 'start' , proc_name , params ) ;
388+ return this . dispatch ( 'start' , proc_name , this . _clean_params ( params ) ) ;
372389 } ,
373390
374391 stop_proc : function ( proc_name ) {
0 commit comments