{"record":{"id":"df75df185ed94461","repo":"dgtlmoon/changedetection.io","slug":"is-not-a-valid-bool-value","errorCode":null,"errorMessage":"\"{}\" is not a valid bool value","messagePattern":"\"(.+?)\" is not a valid bool value","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"changedetectionio/strtobool.py","lineNumber":25,"sourceCode":"    'true': True,\n    'on': True,\n    '1': True,\n    'n': False,\n    'no': False,\n    'f': False,\n    'false': False,\n    'off': False,\n    '0': False\n}\n\n\ndef strtobool(value):\n    if not value:\n        return False\n    try:\n        return _MAP[str(value).lower()]\n    except KeyError:\n        raise ValueError('\"{}\" is not a valid bool value'.format(value))\n","sourceCodeStart":7,"sourceCodeEnd":26,"githubUrl":"https://github.com/dgtlmoon/changedetection.io/blob/5d9c7c6da76340597243e8163c4f2439237fa0e8/changedetectionio/strtobool.py#L7-L26","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nrequests.get(url, params={'parse': 'enabled'})\n# after\nrequests.get(url, params={'parse': 'true'})","handlingStrategy":"validation","validationCode":"BOOL_STRINGS = {'true','false','1','0','yes','no','on','off','t','f','y','n'}\nval = raw.strip().strip('\"\\'').lower()\nif val and val not in BOOL_STRINGS:\n    val = 'true' if raw.strip().strip('\"\\'') in (1, '1') else 'false'\n# or simply: pass only canonical values","typeGuard":"def is_boolish(v: str) -> bool:\n    return v.strip().lower() in {'y','yes','t','true','on','1','n','no','f','false','off','0'}","tryCatchPattern":"from changedetectionio.strtobool import strtobool\ntry:\n    flag = strtobool(raw_param)\nexcept ValueError:\n    flag = False  # or return HTTP 400 with the offending value","preventionTips":["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"],"tags":["strtobool","query-params","value-error","api"],"backgroundTag":"invalid-boolean-value","analyzedSha":"5d9c7c6da76340597243e8163c4f2439237fa0e8","analyzedAt":"2026-08-27T19:41:16.067Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}