{"record":{"id":"6d8323d7269953c9","repo":"666ghj/MiroFish","slug":"reviewed-watermark-data-is-invalid","errorCode":null,"errorMessage":"reviewed watermark data is invalid","messagePattern":"reviewed watermark data is invalid","errorType":"exception","errorClass":"StarHistoryError","httpStatus":null,"severity":"error","filePath":"scripts/star_history.py","lineNumber":1263,"sourceCode":"                raise StarHistoryError(\"generated SVG contains an external resource\")\n            if lowered.startswith((\"http:\", \"https:\", \"//\")):\n                raise StarHistoryError(\"generated SVG contains an external resource\")\n    if avatar_count != 1 or watermark_count != 1:\n        raise StarHistoryError(\"generated SVG must contain both reviewed images\")\n    try:\n        avatar = base64.b64decode(OWNER_AVATAR_BASE64, validate=True)\n    except ValueError as exc:\n        raise StarHistoryError(\"reviewed avatar data is invalid\") from exc\n    if (\n        len(avatar) > MAX_INLINE_AVATAR_BYTES\n        or hashlib.sha256(avatar).hexdigest() != OWNER_AVATAR_SHA256\n        or _reviewed_avatar_dimensions(avatar) != OWNER_AVATAR_DIMENSIONS\n    ):\n        raise StarHistoryError(\"reviewed avatar data is invalid\")\n    try:\n        watermark = base64.b64decode(WATERMARK_LOGO_BASE64, validate=True)\n    except ValueError as exc:\n        raise StarHistoryError(\"reviewed watermark data is invalid\") from exc\n    png_header = (\n        watermark.startswith(b\"\\x89PNG\\r\\n\\x1a\\n\")\n        and watermark[8:12] == (13).to_bytes(4, \"big\")\n        and watermark[12:16] == b\"IHDR\"\n        and len(watermark) >= 33\n    )\n    watermark_dimensions = (\n        (\n            int.from_bytes(watermark[16:20], \"big\"),\n            int.from_bytes(watermark[20:24], \"big\"),\n        )\n        if png_header\n        else None\n    )\n    if (\n        len(watermark) > MAX_INLINE_WATERMARK_BYTES\n        or not png_header\n        or watermark_dimensions != WATERMARK_LOGO_DIMENSIONS","sourceCodeStart":1245,"sourceCodeEnd":1281,"githubUrl":"https://github.com/666ghj/MiroFish/blob/b5b53acc57189a4a42e44a23e149dc655c98fe82/scripts/star_history.py#L1245-L1281","documentation":"Raised by _validate_svg when base64.b64decode(WATERMARK_LOGO_BASE64, validate=True) throws ValueError — the hard-coded watermark constant (scripts/star_history.py:61) is not strict base64. Like error 206, this is self-validation of the script's embedded constants, so it fires only when that literal was corrupted or hand-edited; the ValueError is chained as the cause.","triggerScenarios":"Hand-editing WATERMARK_LOGO_BASE64: inserted whitespace/newlines, URL-safe alphabet characters, wrong padding, truncated paste, or merge-conflict residue inside the multi-line string literal.","commonSituations":"Rebranding the star-history.com watermark; copying base64 from a tool that wraps at 76 columns or percent-escapes characters; a bad merge on the long constant block.","solutions":["Regenerate the constant programmatically: base64.b64encode(watermark_png_bytes).decode('ascii') from the reviewed PNG and paste without reformatting.","Strict-decode check it in isolation before running the pipeline (validate=True).","Update WATERMARK_LOGO_SHA256 and WATERMARK_LOGO_DIMENSIONS in the same change or error 209 fires next.","Inspect git diff around line 61 for wrapping or conflict markers."],"exampleFix":"# before: wrapped/edited literal\nWATERMARK_LOGO_BASE64 = (\n    \"iVBORw0KGgoAAAANSUhEUg...\"   # hand-truncated\n)\n\n# after: single atomic regeneration\nWATERMARK_LOGO_BASE64 = base64.b64encode(\n    pathlib.Path(\"assets/watermark-64.png\").read_bytes()\n).decode(\"ascii\")","handlingStrategy":"validation","validationCode":"import base64\n\ntry:\n    base64.b64decode(WATERMARK_LOGO_BASE64, validate=True)\nexcept ValueError:\n    raise SystemExit(\"WATERMARK_LOGO_BASE64 is not strict base64; regenerate it\")","typeGuard":null,"tryCatchPattern":"try:\n    _validate_svg(svg_bytes)\nexcept StarHistoryError as exc:\n    if \"watermark data is invalid\" in str(exc) and isinstance(exc.__cause__, ValueError):\n        # the watermark base64 literal is malformed; regenerate from the source PNG\n        ...","preventionTips":["Generate the watermark base64 programmatically from the reviewed PNG.","Strict-decode it in a unit test.","Re-check the literal after any rebranding or merge touching line 61."],"tags":["base64","assets","watermark","data-integrity"],"backgroundTag":null,"analyzedSha":"b5b53acc57189a4a42e44a23e149dc655c98fe82","analyzedAt":"2026-08-14T22:29:33.146Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}