Whole file

guillaumemeyer/watermarks-remover

The author described this change as fix: validate clean option types (#111). It counts as a record because the checks below fail on the code as it stood at 07be21e54 and pass on 5e43d53fc, with nothing else changed between the two runs.

Fix saved2026-08-17
Sharing licenceMIT · LICENSE
Change size+5 1

What the code was meant to do, written into the code itself as a save note

fix: validate clean option types (#111)

The change

462462 options = {}
463463 if not isinstance(options, dict):
464464 raise ValueError("'options' must be an object")
465- for key in options:
465+ for key, value in options.items():
466466 if key not in ALLOWED_CLEAN_OPTIONS:
467467 raise ValueError(f"unknown option: {key}")
468+ expected_type = ALLOWED_CLEAN_OPTIONS[key]
469+ if not isinstance(value, expected_type):
470+ type_name = "boolean" if expected_type is bool else "string"
471+ raise ValueError(f"option {key!r} must be a {type_name}")
468472
469473 with tempfile.TemporaryDirectory(prefix="wm-clean-") as tmp:
470474 tmpdir = Path(tmp)

The check that tells the two apart

failpass·tests/test_http_server.py::test_option_wrong_type_rejected[aggressive_homoglyphs-1-boolean]
failpass·tests/test_http_server.py::test_option_wrong_type_rejected[also_layer_a_text-value3-boolean]
failpass·tests/test_http_server.py::test_option_wrong_type_rejected[keep_non_ai_metadata-None-boolean]
failpass·tests/test_http_server.py::test_option_wrong_type_rejected[nfkc-false-boolean]
failpass·tests/test_http_server.py::test_option_wrong_type_rejected[remove_pixel-False-string]
failpass·tests/test_http_server.py::test_option_wrong_type_rejected[strip_all_metadata-value4-boolean]

Check file tests/test_http_server.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it07be21e54ab95ecbb0cbb66f34f5098d2a54178f
Broken version dated2026-08-17
Moduleservice.scripts.server
Units changedHandler
Fingerprintd5b97c45b4125e76
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in guillaumemeyer/watermarks-remover