Skip to content
This repository was archived by the owner on May 6, 2026. It is now read-only.

fix: raise ValueError instead of silent sys.exit(1) for empty deck data#116

Merged
aalemayhu merged 3 commits intomainfrom
fix/empty-deck-error-message
May 4, 2026
Merged

fix: raise ValueError instead of silent sys.exit(1) for empty deck data#116
aalemayhu merged 3 commits intomainfrom
fix/empty-deck-error-message

Conversation

@aalemayhu
Copy link
Copy Markdown
Contributor

Summary

  • sys.exit(1) raises SystemExit, which is a BaseException — not caught by the except Exception block
  • When a page produces no cards, the script exited with code 1 and produced zero output, making the server log "Python script exited with code 1: (no output)" with nothing to debug
  • Fix: raise ValueError with a clear message so the except block catches it, logs it to stderr, and sends the production error email

Test plan

  • Pass an empty JSON array as deck data — error message now appears in stderr and server logs
  • Existing test suite passes

🤖 Generated with Claude Code

aalemayhu and others added 3 commits April 12, 2026 17:10
Filter out non-existent media files before passing to genanki, so users still get their flashcards even if images are missing from the upload.
sys.exit(1) raises SystemExit which is not caught by the except Exception
block, so failures from empty pages produced no output and no error email.
Replacing with ValueError gives the caller a useful message in stderr and
triggers the production error email flow.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
stdout is the machine-readable channel — it carries only the final .apkg
file path. Warnings and error messages going to stdout could corrupt that
output and cause the Node.js caller to resolve with a warning string instead
of a valid path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 4, 2026

@aalemayhu aalemayhu merged commit 442e708 into main May 4, 2026
8 checks passed
@aalemayhu aalemayhu deleted the fix/empty-deck-error-message branch May 4, 2026 20:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant