{"record":{"id":"60ba44d2d8d780b4","repo":"dgtlmoon/changedetection.io","slug":"invalid-json-object-for-field-value","errorCode":null,"errorMessage":"Invalid JSON object for field: {value}","messagePattern":"Invalid JSON object for field: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"changedetectionio/api/Import.py","lineNumber":78,"sourceCode":"        else:\n            prop_type = None\n\n    # Handle array type (e.g., notification_urls)\n    if prop_type == 'array':\n        # Support both comma-separated and JSON array format\n        if value.startswith('['):\n            try:\n                return json.loads(value)\n            except json.JSONDecodeError:\n                return [v.strip() for v in value.split(',')]\n        return [v.strip() for v in value.split(',')]\n\n    # Handle object type (e.g., time_between_check, headers)\n    elif prop_type == 'object':\n        try:\n            return json.loads(value)\n        except json.JSONDecodeError:\n            raise ValueError(f\"Invalid JSON object for field: {value}\")\n\n    # Handle boolean type\n    elif prop_type == 'boolean':\n        return strtobool(value)\n\n    # Handle integer type\n    elif prop_type == 'integer':\n        return int(value)\n\n    # Handle number type (float)\n    elif prop_type == 'number':\n        return float(value)\n\n    # Default: return as string\n    return value\n\n\nclass Import(Resource):","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/dgtlmoon/changedetection.io/blob/5d9c7c6da76340597243e8163c4f2439237fa0e8/changedetectionio/api/Import.py#L60-L96","documentation":"This ValidationError is raised by the XPath validator in changedetectionio when lxml's tree.xpath() raises XPathEvalError while compiling a user-supplied XPath expression. It means the expression is syntactically invalid per the XPath 1.0 grammar that lxml/libxml2 supports. The message embeds both the bad expression and the underlying libxml2 error string.","triggerScenarios":"Submitting a watch/filter form where a CSS/XPath-like field contains a line that lxml fails to compile, e.g. 'div[' (unclosed bracket), '///text()', or unsupported XPath 2.0 syntax like 'matches(...)' or 'if/then/else'. Each newline-separated line is stripped and compiled against an empty <html> doc under an lxml lock in forms.py __call__.","commonSituations":"Copy-pasting browser DevTools 'Copy XPath' output that contains quotes/newlines; using XPath 2.0+ functions unsupported by libxml2 (matches, lowercase, string-join); typos in filters like missing closing brackets; pasting CSS selectors (div.foo) instead of XPath (//div[@class='foo']).","solutions":["Fix the XPath syntax as reported in the embedded %(error)s text from libxml2","Wrap browser-copied expressions: //tag[@class='x'] instead of CSS selectors","Use 'css:' prefix in changedetectionio if you want CSS selectors instead of raw XPath","Test the expression in a REPL: lxml.html.fromstring('<html></html>').xpath(expr)"],"exampleFix":"# before\n//div[@class='item  # missing closing bracket\n# after\n//div[@class='item']","handlingStrategy":"validation","validationCode":"from lxml import html, etree\n\ndef xpath_ok(expr: str) -> bool:\n    try:\n        tree = html.fromstring('<html></html>')\n        v = tree.xpath(expr)\n        return isinstance(v, list)\n    except (etree.XPathEvalError, etree.XPathSyntaxError):\n        return False\n    except Exception:\n        return False","typeGuard":"def is_valid_xpath(expr: str) -> bool:\n    try:\n        html.fromstring('<html></html>').xpath(expr)\n        return True\n    except etree.XPathError:\n        return False","tryCatchPattern":"try:\n    form.validate()\nexcept ValidationError as e:\n    if 'not a valid XPath' in str(e):\n        # show embedded libxml2 detail to the user\n        ...","preventionTips":["Run lxml .xpath() on a scratch document before submitting the form","Use browser 'Copy XPath' then verify balanced quotes/brackets","Prefer the css: prefix for CSS selectors instead of hand-writing XPath"],"tags":["xpath","lxml","form-validation","changedetectionio"],"backgroundTag":"xpath-expression-invalid","analyzedSha":"5d9c7c6da76340597243e8163c4f2439237fa0e8","analyzedAt":"2026-08-27T19:41:16.067Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}