Files
OCR/backend/app/services
egg 9621d6a242 fix: handle None image_path safely to prevent AttributeError
Fix bug introduced in previous commit where image_path=None caused
AttributeError when calling .lower() on None value.

**Problem**:
Setting image_path to None for table placeholders caused crashes at:
- Line 415: 'table' in img.get('image_path', '').lower()
- Line 453: 'table' not in img.get('image_path', '').lower()

When key exists but value is None, .get('image_path', '') returns None
(not default value), causing .lower() to fail.

**Solution**:
Use img.get('type') == 'table' to identify table entries instead of
checking image_path string. This is:
- More explicit and reliable
- Safer (no string operations on potentially None values)
- Cleaner code

**Changes**:
- Line 415: Check img.get('type') == 'table' for table count
- Line 453: Filter using img.get('type') != 'table' and image_path is not None
- Added informative log message showing table count

**Verification**:
draw_image_region already safely handles None/empty image_path (lines 1013-1015)
by returning early if not image_path_str.

Task 2.1 now fully functional without crashes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 07:36:14 +08:00
..
2025-11-12 22:53:17 +08:00
2025-11-12 22:53:17 +08:00