dgtlmoon/changedetection.io · warning · ValueError
"{}" is not a valid bool value
Error message
"{}" is not a valid bool value What it means
ValueError raised by changedetectionio.strtobool when the supplied value is truthy but not one of the recognized boolean strings ('y','yes','t','true','on','1' and negatives 'n','no','f','false','off','0'), matched case-insensitively. It is the project's standard parser for query params and env-ish settings, so it surfaces wherever a caller feeds it free text.
Source
Thrown at changedetectionio/strtobool.py:25
'true': True,
'on': True,
'1': True,
'n': False,
'no': False,
'f': False,
'false': False,
'off': False,
'0': False
}
def strtobool(value):
if not value:
return False
try:
return _MAP[str(value).lower()]
except KeyError:
raise ValueError('"{}" is not a valid bool value'.format(value))
View on GitHub (pinned to 5d9c7c6da7)
Solutions
- Send only canonical boolean strings: true/false, 1/0, yes/no, on/off (case-insensitive)
- Strip quotes/whitespace from values before passing them to strtobool
- If you control the caller, send empty or omit the param rather than a junk value
- Add a pre-check mapping/whitelist before invoking endpoints that use strtobool
Example fix
# before
requests.get(url, params={'parse': 'enabled'})
# after
requests.get(url, params={'parse': 'true'}) Defensive patterns
Strategy: validation
Validate before calling
BOOL_STRINGS = {'true','false','1','0','yes','no','on','off','t','f','y','n'}
val = raw.strip().strip('"\'').lower()
if val and val not in BOOL_STRINGS:
val = 'true' if raw.strip().strip('"\'') in (1, '1') else 'false'
# or simply: pass only canonical values Type guard
def is_boolish(v: str) -> bool:
return v.strip().lower() in {'y','yes','t','true','on','1','n','no','f','false','off','0'} Try / catch
from changedetectionio.strtobool import strtobool
try:
flag = strtobool(raw_param)
except ValueError:
flag = False # or return HTTP 400 with the offending value Prevention
- Send lowercase true/false in query strings and JSON — never 'True', 'enabled', or quoted values
- Strip whitespace/quotes in any proxy layer that forwards user input
- Treat parse failures as 400s in your API client, with the offending value echoed back
When it happens
Trigger: Calling strtobool('yeah'), strtobool('enable'), strtobool(None) is safe (returns False) but strtobool('2') or any non-mapped string raises ValueError. Real call sites include REST API query params (?unread=true&parse=true), browsersteps UI updates, and main() config parsing.
Common situations: API clients sending ?parse=yes-please or ?unread=TRUE with trailing whitespace/quotes; copy-pasted curl commands with typo'd boolean flags; integrations sending 'True'/'False' with quotation marks from JSON bodies.
Related errors
- Invalid day_of_week: '{day_of_week}'. Must be a valid weekda
- Invalid time_str: '{time_str}'. Must be in 'HH:MM' format.
- Invalid timezone_str: '{timezone_str}'. Must be a valid time
AI-assisted analysis of dgtlmoon/changedetection.io@5d9c7c6da7 (2026-08-27).
Data as JSON: /api/errors/df75df185ed94461.
Report an issue: GitHub.