Repository: buildbot/buildbot

Issue:
Default value is set wrong when triggerring a forcescheduler by REST API
Assume that we have a forcescheduler like below:
```python
ForceBuild_Scheduler = ForceScheduler(
    name="ForceBuild_Scheduler",
    buttonName=u"Force,
    label=u"Force",
    builderNames=["BuildEntry_Builder"],
    username=util.UserNameParameter(hide=True),
    reason=util.StringParameter(name="reason", default="force build", hide=True),
    codebases=[util.CodebaseParameter(codebase='', hide=True)],
    properties=[util.BooleanParameter(name="DefaultToBeTrue",
                                      label=u"",
                                      default=True))
```
And trigger this scheduler by sending a post with body like below which doesn't contain value of `DefaultToBeTrue`.
```json
{
	"jsonrpc": "2.0",
	"method":"force",
	"id":843,
	"params":{
	}
}
```
And then you can find that `self.getProperty('DefaultToBeTrue')` whose default value is set to `True` returns `False` in your buildstep. 
Default value is set wrong when triggerring a forcescheduler by REST API
Assume that we have a forcescheduler like below:
```python
ForceBuild_Scheduler = ForceScheduler(
    name="ForceBuild_Scheduler",
    buttonName=u"Force,
    label=u"Force",
    builderNames=["BuildEntry_Builder"],
    username=util.UserNameParameter(hide=True),
    reason=util.StringParameter(name="reason", default="force build", hide=True),
    codebases=[util.CodebaseParameter(codebase='', hide=True)],
    properties=[util.BooleanParameter(name="DefaultToBeTrue",
                                      label=u"",
                                      default=True))
```
And trigger this scheduler by sending a post with body like below which doesn't contain value of `DefaultToBeTrue`.
```json
{
	"jsonrpc": "2.0",
	"method":"force",
	"id":843,
	"params":{
	}
}
```
And then you can find that `self.getProperty('DefaultToBeTrue')` whose default value is set to `True` returns `False` in your buildstep. 


Discussion:
`self.getProperty('DefaultToBeTrue')` should return `None` to avoid this confusion.
good catch..

problem is in this code:
https://github.com/buildbot/buildbot/blob/master/master/buildbot/schedulers/forcesched.py#L252

        return kwargs.get(self.fullName, None) == [True]

should probably be something like

        return kwargs.get(self.fullName, [self.default]) == [True]


could you try it and submit a PR?
`self.getProperty('DefaultToBeTrue')` should return `None` to avoid this confusion.
good catch..

problem is in this code:
https://github.com/buildbot/buildbot/blob/master/master/buildbot/schedulers/forcesched.py#L252

        return kwargs.get(self.fullName, None) == [True]

should probably be something like

        return kwargs.get(self.fullName, [self.default]) == [True]


could you try it and submit a PR?

Resolving patch:
diff --git a/master/buildbot/schedulers/forcesched.py b/master/buildbot/schedulers/forcesched.py
--- a/master/buildbot/schedulers/forcesched.py
+++ b/master/buildbot/schedulers/forcesched.py
@@ -249,7 +249,7 @@ class BooleanParameter(BaseParameter):
     type = "bool"
 
     def getFromKwargs(self, kwargs):
-        return kwargs.get(self.fullName, None) == [True]
+        return kwargs.get(self.fullName, [self.default]) == [True]
 
 
 class UserNameParameter(StringParameter):


Test patch: