Skip to content

fix: narrow OperationalError catch in delete_student to table-not-found only - #86

Open
clates wants to merge 4 commits into
mainfrom
fix/delete-student-broad-catch
Open

fix: narrow OperationalError catch in delete_student to table-not-found only#86
clates wants to merge 4 commits into
mainfrom
fix/delete-student-broad-catch

Conversation

@clates

@clates clates commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • The existing except sqlite3.OperationalError: pass in delete_student was introduced in PR#85 to handle the case where weekly_packets doesn't exist in minimal test DBs.
  • However, sqlite3.OperationalError is a wide exception class that also covers disk-full errors, database-locked errors, corrupted database pages, and future typos in table names — all of which were silently swallowed with pass.
  • This fix narrows the handler to check "no such table" in str(e) and re-raises any other OperationalError, so real failures surface immediately rather than being hidden.

Test plan

  • Verify that deleting a student against a minimal test DB (without weekly_packets) still succeeds without error
  • Verify that a simulated non-table OperationalError (e.g. "database is locked") is now propagated rather than suppressed
  • Run pytest tests/ -k "delete" -v once a Python 3.11+ environment is available

🤖 Generated with Claude Code

clates and others added 4 commits June 16, 2026 19:22
… fp precision, cascade deletes

- Add null guards for progress_blob/plan_rules_blob in logic.py, main.py, agent.py
  (issues #77, #78, #79) — new students with NULL blobs no longer crash
- Fix generate_weekly_plan to use datetime.now(UTC) instead of local time
  (issue #80) — prevents off-by-one day in week_of on non-UTC servers
- Fix _get_grade_level to fall back to student metadata instead of literal 0
  (issue #81) — first-time plan generation no longer fails with no-standards error
- Round activity_bias in process/reverse_quantity_feedback to 6 decimal places
  (issue #82) — prevents floating-point drift across feedback cycles
- Replace delete-then-insert with INSERT OR REPLACE in save_weekly_packet
  (issue #83) — eliminates duplicate-packet race condition under concurrent saves
- Cascade-delete weekly_packets before deleting student profile in delete_student
  (issue #84) — packet_feedback no longer left as orphans after student deletion

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Adds two rules to prevent direct commits to main:
- All changes must go through a PR, no exceptions
- Automated analysis/fix workflows must create a branch before making changes,
  then open a PR rather than committing directly

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…l test

- delete_student() now catches OperationalError when weekly_packets table
  doesn't exist (minimal test DBs only have student_profiles)
- Update test_get_grade_level_defaults_to_zero to expect 1 (the new safe
  default) and add a second test covering the metadata_fallback path

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…nd only

The broad `except sqlite3.OperationalError: pass` in delete_student silently
swallowed disk-full, database-locked, and data corruption errors alongside the
intended "no such table: weekly_packets" case. Narrow the handler to only
suppress errors whose message contains "no such table", re-raising everything
else so real failures surface immediately.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Base automatically changed from fix/claude-identified-bugs to main July 9, 2026 04:52
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