fix(ConnectedDeviceInformation): add database query error handling #1398
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a critical bug in ConnectedDeviceInformation.py where the parser would crash when encountering invalid, corrupt, or non-SQLite files that matched the
healthdb*.sqlitefilename pattern.Previously, the script assumed 100% file integrity. If
sqlite3raised aDatabaseError(e.g., "file is not a database"), the exception was unhandled, leading to a complete failure of the artifact extraction. This update implements defensive programming to handle these scenarios gracefully.Changes
try-exceptblocks aroundget_sqlite_db_records()calls in:connected_device_info_device_historyconnected_device_info_consolidated_connected_device_historyconnected_device_information_current_device_infologfunc, anddb_recordsis set to an empty list. This allows the function to return a valid report structure (with zero records) instead of crashing.healthdbfiles and preserves the stability of the extraction process.Verification & Testing
I have created a comprehensive test suite (test_connected_device_fix.py) to verify the fix and ensure no regressions.
DatabaseErroris properly identified.Test Output Summary:
Checklist