The sh.setBalancerState() function in the mongo shell is coded thus:
sh.setBalancerState = function(isOn) { if (isOn) { return sh.startBalancer(); } else { return sh.stopBalancer(); } };
As a consequence, running sh.setBalancerState("true") actually stops the balancer, as does sh.setBalancerState(). These are surprising results.
Suggest adding a type check to the code before the if statement:
if ((typeof isOn) != "boolean") { print error message and exit }