Skip to content

Fix bugs in error handling, URL filtering, and response validation - #6

Merged
dtump merged 2 commits into
mainfrom
fix-bugs-round2
Apr 14, 2026
Merged

Fix bugs in error handling, URL filtering, and response validation#6
dtump merged 2 commits into
mainfrom
fix-bugs-round2

Conversation

@dtump

@dtump dtump commented Apr 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • cli_toolbox.py: Fix inverted error flag logic — was checking is_spam truthiness instead of detecting missing response keys
  • process_email.py: Reuse BeautifulSoup object (was parsing HTML twice); strip whitespace from URLs; filter out data:, javascript:, vbscript:, and mailto: schemes from extracted links/images
  • email_ai_interface.py: Add errors="replace" to file open for consistent encoding handling with rest of codebase
  • external_ai_test.lua: Defensive nil handling for missing confidence field in AI response
  • validation.py (new): Shared AI response validation — normalizes is_spam to yes/no, clamps confidence to 0-100, ensures reason is a string. Used by both Anthropic and OpenAI providers.
  • 15 new tests (57 total)

Test plan

  • ruff check . && ruff format --check . — clean
  • pytest -v — 57 tests pass
  • Verify CI passes

dtump added 2 commits April 14, 2026 23:26
- Fix cli_toolbox.py error flag: was checking is_spam truthiness instead
  of checking for missing response keys
- Fix process_email.py: reuse BeautifulSoup object instead of parsing
  HTML twice; strip whitespace from URLs; filter out data:, javascript:,
  vbscript:, and mailto: schemes from extracted links/images
- Fix email_ai_interface.py: add errors="replace" to file open for
  consistent encoding handling with rest of codebase
- Fix external_ai_test.lua: defensive nil handling for missing
  confidence field in AI response
- Add response validation (email_utils/validation.py): normalize
  is_spam to yes/no, clamp confidence to 0-100, ensure reason is string
- Add 15 new tests (57 total): validation logic, URL filtering,
  data URI filtering, whitespace stripping
@dtump
dtump merged commit 713f64a into main Apr 14, 2026
4 checks passed
@dtump
dtump deleted the fix-bugs-round2 branch April 15, 2026 06:10
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