Skip to content

fix: make exception broader so it can catch DatabaseError also#1378

Merged
JamesHabben merged 2 commits into
abrignoni:mainfrom
zelvann:fix-file-isnt-db
Jun 16, 2026
Merged

fix: make exception broader so it can catch DatabaseError also#1378
JamesHabben merged 2 commits into
abrignoni:mainfrom
zelvann:fix-file-isnt-db

Conversation

@zelvann

@zelvann zelvann commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

When the file was not a valid database, the code raised a DatabaseError that wasn’t being caught, since only OperationalError and ProgrammingError were handled. This PR broadens the exception handling to properly cover DatabaseError as well.

Before:

Query error, query=SELECT name FROM sqlite_master WHERE type='table' AND name='workout_activities' Error=file is not a database
Reading health_workouts artifact had errors!
Error was file is not a database
Exception Traceback: Traceback (most recent call last): File "E:\forensik\iLEAPP\ileapp.py", line 491, in crunch_artifacts plugin.method(files_found, category_folder, seeker, wrap_text, time_offset) File "E:\forensik\iLEAPP\scripts\ilapfuncs.py", line 359, in wrapper data_headers, data_list, source_path = func(Context) ^^^^^^^^^^^^^ File "E:\forensik\iLEAPP\scripts\artifacts\health.py", line 531, in health_workouts db_records = get_sqlite_db_records(data_source, query, attach_query) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\forensik\iLEAPP\scripts\ilapfuncs.py", line 583, in get_sqlite_db_records cursor.execute(attach_query) sqlite3.DatabaseError: file is not a database

After:

Query error, query=SELECT name FROM sqlite_master WHERE type='table' AND name='workout_activities' Error=file is not a database
Error with \\?\E:\forensik\iLEAPP_Reports_2025-12-07_Sunday_001201\data\iOS_Filesystem\private\var\mobile\Library\Health\healthdb_secure.sqlite:
- file is not a database
No data found for Health - Workouts
health_workouts [health] artifact completed

As a result, the parsing operation can complete without the exception being thrown immediately.

ref: https://docs.python.org/3/library/sqlite3.html

@JamesHabben

Copy link
Copy Markdown
Collaborator

updated the exception because the proposed fix is way too broad. using DatabaseError will include the intended error with this pr, but also include the other errors that were on separate lines. thanks for finding this issue.

@JamesHabben JamesHabben merged commit b25520d into abrignoni:main Jun 16, 2026
1 check failed
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.

2 participants