Skip to content

Conversation

@Jrjy3
Copy link
Contributor

@Jrjy3 Jrjy3 commented Nov 8, 2025

Issue

Application crashes with AttributeError: 'NoneType' object has no attribute 'value' when downloading from users/subreddits that have NULL post_sort_method in the database.

Root Cause

Database records with NULL post_sort_method (from legacy data or incomplete migrations) cause a crash at download_runner.py:372 when the code attempts to access .value on None.

Stack Trace

File "download_runner.py", line 372, in get_raw_submissions
AttributeError: 'NoneType' object has no attribute 'value'

Full Stack Trace

{
    "levelname": "CRITICAL",
    "asctime": "11/07/2025 08:14:41 PM",
    "filename": "main.py",
    "module": "main",
    "name": "DownloaderForReddit.__main__",
    "funcName": "log_unhandled_exception",
    "lineno": 48,
    "message": "Unhandled exception",
    "exc_info": "Traceback (most recent call last):\n  File \"DownloaderForReddit\\core\\download_runner.py\", line 195, in run\n  File \"DownloaderForReddit\\core\\download_runner.py\", line 243, in run_download\n  File \"DownloaderForReddit\\core\\runner.py\", line 12, in check\n  File \"DownloaderForReddit\\core\\download_runner.py\", line 282, in get_reddit_object_submissions\n  File \"DownloaderForReddit\\core\\runner.py\", line 12, in check\n  File \"DownloaderForReddit\\core\\download_runner.py\", line 296, in get_user_submissions\n  File \"DownloaderForReddit\\core\\download_runner.py\", line 311, in handle_submissions\n  File \"DownloaderForReddit\\core\\runner.py\", line 12, in check\n  File \"DownloaderForReddit\\core\\download_runner.py\", line 336, in get_submissions\n  File \"DownloaderForReddit\\core\\download_runner.py\", line 372, in get_raw_submissions\nAttributeError: 'NoneType' object has no attribute 'value'"
}

Solution

Add null check with fallback to PostSortMethod.NEW (the schema default) before accessing sort_method.value. The record is updated in-place to prevent future errors.

Migration

No database migration required. NULL values are handled at runtime and auto-corrected on first access.

Testing

Tested with database containing 163 NULL records. All downloads complete successfully with auto-correction.

…nload_runner

When post_sort_method is NULL in database records, download_runner.py line 372
crashes with AttributeError when accessing sort_method.value. This occurs during
user/subreddit downloads with legacy records or incomplete migrations.

Stack trace:
  download_runner.py:372 in get_raw_submissions
  AttributeError: 'NoneType' object has no attribute 'value'

Add null check with fallback to PostSortMethod.NEW (schema default) before
accessing sort_method.value. Updates the record in-place on first access to
prevent subsequent errors.

No migration required - NULL values are handled at runtime and auto-corrected.

Resolves crash when downloading from users/subreddits with NULL sort method.
@MalloyDelacroix MalloyDelacroix merged commit 479ef17 into MalloyDelacroix:master Nov 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants