Fix AttributeError when post_sort_method is NULL #404
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Application crashes with
AttributeError: 'NoneType' object has no attribute 'value'when downloading from users/subreddits that have NULLpost_sort_methodin the database.Root Cause
Database records with NULL
post_sort_method(from legacy data or incomplete migrations) cause a crash atdownload_runner.py:372when the code attempts to access.valueon None.Stack Trace
Full Stack Trace
Solution
Add null check with fallback to
PostSortMethod.NEW(the schema default) before accessingsort_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.