← All errors
high captcha

broken data stream when reading image file

Description

The auto-solver crashes with a Pillow error when trying to read the captcha image downloaded from Discord.

Cause

The image download from Discord was incomplete or corrupt. Pillow's Image.open() is lazy — it only fully decodes the image when .load() or a pixel operation is called, so corrupt bytes pass the open() check and crash later inside ONNX.

Fix

In captcha_solver/solve.py, call handle.load() before np.asarray(). In cogs/captcha.py, validate the downloaded bytes with Image.open(BytesIO(img_data)).load() before writing to disk. If it raises, skip the solve.

Code change

Before
handle = Image.open(source)
return np.asarray(handle.convert('RGB'))
After
handle = Image.open(source)
handle.load()
return np.asarray(handle.convert('RGB'))