Fix teleguard Messages media: skip cache dirs, drop unresolved refs (LAVA crash)#858
Merged
Conversation
The Messages media matcher matched cache entries with a loose substring (key in path). The metadata key is a sub-path (TeleGuard stores items at cache/<key>/<file>), so the match also hit the cache/<key> directory. check_in_media() returns None for a directory, and that None was appended into the media list -> serialized as 'null' in the JSON cell -> the LAVA viewer showed a broken-media marker and crashed on hover (the HTML report silently skipped it, so it only reproduced in LAVA). Fix: require os.path.isfile on the match (the directory is never selected) and only append the ref if check_in_media returned one. Collapse a single attachment to a bare ref so it renders like any other single-media cell; keep a list only for genuine multi-attachment messages.
stark4n6
pushed a commit
to stark4n6/ALEAPP
that referenced
this pull request
Jun 22, 2026
…Emails check_in_media() returns None when its path does not resolve to a checked-in file (a matched directory, or a missing file). That None was being appended into media-typed list columns; lava_insert_sqlite_data json.dumps's a list cell, so it became e.g. ["ref", null]. The LAVA viewer parses the array, hits null, shows a broken-media marker and crashes (black screen) on hover. The HTML path (get_data_list_with_media) silently skips unresolved refs, so it only reproduced in LAVA. Same bug class fixed for teleguard in abrignoni#858. For each artifact: capture the ref first and append only when truthy, and require os.path.isfile on the loose path match so a directory is never passed to check_in_media. Collapse a single resolved ref to a bare value (list only for genuine multi-attachment cells, '' when none resolve), mirroring teleguard. No change to which files are matched. FairEmail.py: Attachments and Content columns (also drops the stray 0 sentinel in the Attachments media cell). SamsungNotes.py: Media column. gmailIMAPEmails.py: Attachments column (received + sent paths).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Bug reported while testing the converted Teleguard - Messages artifact in LAVA: the Media column showed a red broken-media marker and the viewer crashed (black screen) on hover, even though the images rendered fine in the HTML report.
Root cause
The media matcher used a loose substring match (
key in str(f)). TeleGuard stores each attachment atcache/<key>/<file>, so the metadatakeyis a sub-path, and the substring also matched thecache/<key>directory.check_in_media()returnsNonefor a directory, and thatNonewas appended into the media list.lava_insert_sqlite_datajson.dumps's a list cell, so it became["validref", null]; the LAVA viewer chokes on thenull(broken marker + crash on hover). The HTML path (get_data_list_with_media) silently skips unresolved refs, which is why it only reproduced in LAVA.Fix
os.path.isfileon the match, so thecache/<key>directory is never selected.if check_in_media(...)returned one (noNonein the cell).Kept the substring match itself (not exact-basename) because the key is a sub-path, not a filename — exact-basename matches nothing and the media goes N/A.
Verification
teleguard_database.dbmodelling thecache/<key>/<file>layout (inner basename != key) with the cache directories present infiles_found: resolves the inner file, skips both directories, never emitsNone, single attachment → bare ref, missing/text rows → empty.-d C,R); PluginLoader loads 492.