Skip to content

fix(update-db): accept JSON from argv[1] as well as stdin#11

Open
tyrannomark wants to merge 2 commits into
m98:mainfrom
tyrannomark:fix/update-db-argv-stdin
Open

fix(update-db): accept JSON from argv[1] as well as stdin#11
tyrannomark wants to merge 2 commits into
m98:mainfrom
tyrannomark:fix/update-db-argv-stdin

Conversation

@tyrannomark

Copy link
Copy Markdown

Summary

  • update-db.py read its JSON payload exclusively from stdin (json.load(sys.stdin))
  • When invoked as a Claude Code background task, JSON is passed as a command-line argument — the script blocks indefinitely waiting for stdin that never arrives
  • All 6 learner databases go un-updated silently for every session run this way

Fix

Check sys.argv[1] first; fall back to stdin if absent. Both invocation styles now work:

# argv style (Claude Code background tasks)
python3 update-db.py "$JSON_PAYLOAD"

# stdin style (shell pipes, heredocs)
echo "$JSON_PAYLOAD" | python3 update-db.py

Test plan

  • python3 update-db.py "$PAYLOAD" — updates all 6 DBs, exits 0
  • echo "$PAYLOAD" | python3 update-db.py — updates all 6 DBs, exits 0
  • Existing test suite passes unchanged

Generated with Claude Code

tyrannomark and others added 2 commits June 28, 2026 12:21
- /fluent-review --batch and /fluent-vocab --batch: present all questions
  upfront as a numbered list, accept all answers in one reply, then
  evaluate in sequence — reduces round-trip latency during review sessions

- /fluent-export-anki: export all SR items to an Anki-importable TSV
  (export-anki.py); Basic cards with front=target content, back=translation
  + category + level; tagged by type, category, and mastery level; safe to
  re-import (Anki deduplicates by front field)

- /fluent-import-lr: import vocabulary from a Language Reactor zip or CSV
  (import-lr.py); deduplicates against existing SR items; spreads due dates
  at --daily-limit items/day (default 20) to avoid flooding the queue;
  writes atomically with backup; dry-run flag for preview before committing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When invoked as a background task by Claude Code the JSON payload is
passed as a command-line argument, not piped to stdin. The script was
blocking forever waiting for stdin that never arrived, silently leaving
all 6 databases un-updated.

Now reads sys.argv[1] if present, falls back to stdin — both invocation
styles work.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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