Skip to content

Commit df42e25

Browse files
authored
When starting a task/process, suppress params where value is null (#82)
This should reduce version mismatch issues when newer panels support (optional) extended parameters.
1 parent 6bbd1c4 commit df42e25

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

src/ocsbow.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)