dgtlmoon/changedetection.io · warning · ValidationError

Bounding box must be in format: x,y,width,height (integers o

Error message

Bounding box must be in format: x,y,width,height (integers only)

What it means

The bounding box validator requires the exact shape ^\d+,\d+,\d+,\d+$ — four non-negative integers separated by single commas, nothing else. Anything else (floats, spaces, labels, fewer/more parts) fails this regex and raises ValidationError.

Source

Thrown at changedetectionio/processors/image_ssim_diff/forms.py:23

from wtforms import SelectField, StringField, validators, ValidationError, IntegerField
from flask_babel import lazy_gettext as _l
from changedetectionio.forms import processor_text_json_diff_form
import re

from changedetectionio.processors.image_ssim_diff import SCREENSHOT_COMPARISON_THRESHOLD_OPTIONS


def validate_bounding_box(form, field):
    """Validate bounding box format: x,y,width,height with integers."""
    if not field.data:
        return  # Optional field

    if len(field.data) > 100:
        raise ValidationError(_l('Bounding box value is too long'))

    # Should be comma-separated integers
    if not re.match(r'^\d+,\d+,\d+,\d+$', field.data):
        raise ValidationError(_l('Bounding box must be in format: x,y,width,height (integers only)'))

    # Validate values are reasonable (not negative, not ridiculously large)
    parts = [int(p) for p in field.data.split(',')]
    for part in parts:
        if part < 0:
            raise ValidationError(_l('Bounding box values must be non-negative'))
        if part > 10000:  # Reasonable max screen dimension
            raise ValidationError(_l('Bounding box values are too large'))


def validate_selection_mode(form, field):
    """Validate selection mode value."""
    if not field.data:
        return  # Optional field

    if field.data not in ['element', 'draw']:
        raise ValidationError(_l('Selection mode must be either "element" or "draw"'))

View on GitHub (pinned to 5d9c7c6da7)

Solutions

  1. Format the value as exactly four comma-separated integers with no spaces: x,y,width,height
  2. Round float coordinates to integers before saving
  3. If your data has spaces, strip them programmatically before form submission

Example fix

# before
field.data = '10.0, 20, 300, 400'
# after
field.data = ','.join(str(int(float(p))) for p in '10.0,20,300,400'.split(','))
Defensive patterns

Strategy: validation

Validate before calling

import re
if not re.fullmatch(r'\d+,\d+,\d+,\d+', bbox or ''):
    bbox = ','.join(str(int(float(p))) for p in bbox.split(','))  # normalize then re-check

Type guard

import re
def is_wellformed_bbox(s: str) -> bool:
    return bool(re.fullmatch(r'\d+,\d+,\d+,\d+', s or ''))

Prevention

When it happens

Trigger: Submitting '10, 20, 300, 400' (spaces), '10.5,20,300,400' (floats), '10,20,300' (three values), or '10,20,300,400px' — all fail re.match before value range checks.

Common situations: Coordinates copied from browser devtools or design tools that include decimals, spaces, units, or brackets; users assuming width/height can be omitted; localized keyboards producing a comma variant character.

Related errors


AI-assisted analysis of dgtlmoon/changedetection.io@5d9c7c6da7 (2026-08-27). Data as JSON: /api/errors/85ef0f5f4c21818e. Report an issue: GitHub.