[GH-ISSUE #105] Bug: AttributeError: 'DownloadUnexpectedStatusError' object has no attribute 'message' on download failure #25

Closed
opened 2026-10-13 19:45:58 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @WhiterFoxGit on GitHub (Jun 16, 2026).
Original GitHub issue: https://github.com/Glitchy-Sheep/boosty-downloader/issues/105

### Description
When a file download fails (for example, due to an expired OK.ru/Odnoklassniki video link returning 400 Bad Request), the application crashes with an AttributeError instead of gracefully logging the error and continuing or retrying.

This happens because the exception handler in download_single_post.py tries to access e.message, but DownloadUnexpectedStatusError (and some other exceptions) do not have a message attribute in Python.

### Environment

  • OS: Windows 11
  • Python version: 3.14
  • boosty-downloader version: Latest (3.0.0)

### Steps to Reproduce

  1. Run boosty-downloader download --username <creator> on a large channel.
  2. Wait until any external/boosty video CDN link expires or returns an unexpected HTTP status (e.g., HTTP 400).
  3. The downloader crashes immediately with the traceback below.

### Traceback

Traceback (most recent call last):
  File "C:\...\boosty_downloader\src\application\use_cases\download_single_post.py", line 228, in _safely_process_chunk
    return await self._process_chunk(chunk, missing_parts)
  ...
  File "C:\...\boosty_downloader\src\infrastructure\file_downloader.py", line 121, in download_file
    raise DownloadUnexpectedStatusError(
boosty_downloader.src.infrastructure.exceptions.DownloadUnexpectedStatusError: Unexpected status code: 400

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  ...
  File "C:\...\boosty_downloader\src\application\use_cases\download_single_post.py", line 246, in _safely_process_chunk
    f'Failed to download file ({e.file}): {e.message}',
AttributeError: 'DownloadUnexpectedStatusError' object has no attribute 'message'

### Suggested Fix
In boosty_downloader/src/application/use_cases/download_single_post.py, inside _safely_process_chunk(), please replace e.message with str(e) or use getattr(e, 'message', str(e)) to avoid crashing on logging.

For example,

except DownloadError as e:
            if e.file:
                e.file.unlink(missing_ok=True)
            
            # Safe error message extraction
            error_message = getattr(e, 'message', str(e))
            
            await self.context.failed_logger.add_error(
                f'{_form_post_url(username=self.context.author_name, post_id=post.uuid)} - {getattr(e, "resource_url", "No URL")}',
                f'Failed to download file ({e.file}): {error_message}',
            )

Also, it might be beneficial to make failed downloads optional or skippable so that one failed CDN video doesn't abort the entire bulk download process.

Originally created by @WhiterFoxGit on GitHub (Jun 16, 2026). Original GitHub issue: https://github.com/Glitchy-Sheep/boosty-downloader/issues/105 **### Description** When a file download fails (for example, due to an expired OK.ru/Odnoklassniki video link returning `400 Bad Request`), the application crashes with an `AttributeError` instead of gracefully logging the error and continuing or retrying. This happens because the exception handler in `download_single_post.py` tries to access `e.message`, but `DownloadUnexpectedStatusError` (and some other exceptions) do not have a `message` attribute in Python. **### Environment** - OS: Windows 11 - Python version: 3.14 - boosty-downloader version: Latest (3.0.0) **### Steps to Reproduce** 1. Run `boosty-downloader download --username <creator>` on a large channel. 2. Wait until any external/boosty video CDN link expires or returns an unexpected HTTP status (e.g., HTTP 400). 3. The downloader crashes immediately with the traceback below. **### Traceback** ```python Traceback (most recent call last): File "C:\...\boosty_downloader\src\application\use_cases\download_single_post.py", line 228, in _safely_process_chunk return await self._process_chunk(chunk, missing_parts) ... File "C:\...\boosty_downloader\src\infrastructure\file_downloader.py", line 121, in download_file raise DownloadUnexpectedStatusError( boosty_downloader.src.infrastructure.exceptions.DownloadUnexpectedStatusError: Unexpected status code: 400 During handling of the above exception, another exception occurred: Traceback (most recent call last): ... File "C:\...\boosty_downloader\src\application\use_cases\download_single_post.py", line 246, in _safely_process_chunk f'Failed to download file ({e.file}): {e.message}', AttributeError: 'DownloadUnexpectedStatusError' object has no attribute 'message' ``` **### Suggested Fix** In boosty_downloader/src/application/use_cases/download_single_post.py, inside _safely_process_chunk(), please replace e.message with str(e) or use getattr(e, 'message', str(e)) to avoid crashing on logging. For example, ```python except DownloadError as e: if e.file: e.file.unlink(missing_ok=True) # Safe error message extraction error_message = getattr(e, 'message', str(e)) await self.context.failed_logger.add_error( f'{_form_post_url(username=self.context.author_name, post_id=post.uuid)} - {getattr(e, "resource_url", "No URL")}', f'Failed to download file ({e.file}): {error_message}', ) ``` **Also**, it might be beneficial to make failed downloads optional or skippable so that one failed CDN video doesn't abort the entire bulk download process.
bsakaguchi 2026-10-13 19:45:58 +00:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@Glitchy-Sheep commented on GitHub (Jun 18, 2026):

Hi! Thanks a lot for the reporting, I'll try to fix that and some other little bugs maybe these weekends.

<!-- gh-comment-id:4740003345 --> @Glitchy-Sheep commented on GitHub (Jun 18, 2026): Hi! Thanks a lot for the reporting, I'll try to fix that and some other little bugs maybe these weekends.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Glitchy-Sheep/boosty-downloader#25
No description provided.