Skip to content

Commit dc301ec

Browse files
authored
chore: add an error handling in _adjust_image_payload (#1172)
* refact: _adjust_image_payload * style: move import binascii * refactor: raise helpful ValueError on UnicodeDecodeError * refactor: add from e * style: ruff formatting
1 parent 6225fd6 commit dc301ec

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

appium/webdriver/extensions/images_comparison.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,7 @@ def _add_commands(self) -> None:
147147

148148

149149
def _adjust_image_payload(payload: Base64Payload) -> str:
150-
return payload if isinstance(payload, str) else payload.decode('utf-8')
150+
try:
151+
return payload if isinstance(payload, str) else payload.decode('utf-8')
152+
except UnicodeDecodeError as e:
153+
raise ValueError('The image payload cannot be serialized to a string. Make sure to base64-encode it first') from e

0 commit comments

Comments
 (0)