Skip to content

fix: validate config, separate comments/submissions, fix crash bugs#1

Open
dbeley wants to merge 1 commit into
masterfrom
fix/config-validation-and-bugs
Open

fix: validate config, separate comments/submissions, fix crash bugs#1
dbeley wants to merge 1 commit into
masterfrom
fix/config-validation-and-bugs

Conversation

@dbeley

@dbeley dbeley commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Bug fixes, config validation, and separation of comments/submissions export options.

Changes

Bug fixes:

  • read_config: Fixed UnboundLocalError crash when config file doesn't exist — now returns None instead of crashing.
  • export_data: Added early return when data is empty to prevent IndexError.
  • reddit_connect: Added None guard in extract_data — if connection fails, returns empty list instead of crashing with AttributeError.
  • Config options access: Changed from direct config["options"] access (could raise KeyError) to safe .get() with defaults.

New features:

  • Separate comments and submissions exports: Previously submissions exported both posts and comments together, while the config example advertised a - comments option that wasn't implemented. Now:
    • comments → exports only user comments
    • submissions → exports only user submissions (posts)
    • If both are wanted, include both in the config list
  • Config validation: Replaced the no-op validate_config() placeholder with real validation that checks for required fields, valid export types, and proper structure. Returns descriptive error messages.

Code quality:

  • Removed format variable that shadowed the built-in format() function (renamed to log_format).
  • Removed dead parser.set_defaults(boolean_flag=False) line referencing a non-existent argument.
  • Reformatted with Black.
  • Removed obsolete # TODO Add config file validation. comment.

- Fix UnboundLocalError in read_config when file is missing
- Fix IndexError in export_data on empty data
- Fix AttributeError when reddit_connect returns None
- Add safe dict access for config options (prevent KeyError)
- Implement proper config validation (structure, required fields,
  valid export types) with descriptive error messages
- Split comments and submissions into separate export options
  (comments → own comments, submissions → own posts)
- Fix format variable shadowing built-in format()
- Remove dead set_defaults(boolean_flag=False) line
- Reformat with Black
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.

1 participant