0 periods Byo-Yomi

A few minutes ago, I saw a
9x9 2m+0x 10s
challenge at the Play page.

(I noted the player’s name too, but figure I shouldn’t post that part here.)

Even if 0 periods is to be allowed, I would think that should warn as Unusual Time Setting.
(Does 2 minutes sudden death give that warning? ​ These two time-settings are equivalent.)

This has occurred before. maybe about a year ago, but my old memory does not remember the resolution.

even if 0 periods is impossible to do, in the code there should be “IF 0 periods, display warn symbol”


The frontend problem should be fixed, but I agree that this should be checked in the backend as well.


So it was a year ago when first reported, as I thought.

I see that at the page joooom linked to, anoek said

we have this line in our backend sanitization
ret["periods"] = min(300, max(1, int(
time_control_parameters["periods"] or "0")))


Is that Python 3? ​ If yes, what happens with a ValueError from int()?
(For example, it could be that, due to this being live code, something will
use 0 rather than halting if it gets a KeyError for ret["periods"].)

1 Like

I saw another one, this time
9x9 5m+nullx 30s ​ ​ ​ .

I believe Python has “None” rather than “hull”, so here are two hypotheses:

the Python hypothesis:

time_control_parameters["periods"] is NaN, or something else truthy that
would cause int to raise ValueError. ​ (I know that in Python 3, NaN is truthy.)
Since the left input is truthy, the or outputs that, and then int accordingly raises ValueError. ​ That exception stops the execution of that Python code, leaving null,
or something that gets treated as such, in whatever location your other code
​- maybe something like C++, maybe database code - reads to get ret["periods"].

the something-else hypothesis:

time_control_parameters["periods"] is either
null or NaN or NA or something similar, and is truthy.
Since time_control_parameters["periods"] is truthy, that is the output of the or.
int of that is null. ​ ​ ​ max and min both output null when one of their inputs is null.