Skip to content

Fix teleguard Messages media: skip cache dirs, drop unresolved refs (LAVA crash)#858

Merged
abrignoni merged 1 commit into
mainfrom
fix-teleguard-media-lava
Jun 22, 2026
Merged

Fix teleguard Messages media: skip cache dirs, drop unresolved refs (LAVA crash)#858
abrignoni merged 1 commit into
mainfrom
fix-teleguard-media-lava

Conversation

@abrignoni

Copy link
Copy Markdown
Owner

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 at cache/<key>/<file>, so the metadata key is a sub-path, and the substring also matched the cache/<key> directory. check_in_media() returns None for a directory, and that None was appended into the media list. lava_insert_sqlite_data json.dumps's a list cell, so it became ["validref", null]; the LAVA viewer chokes on the null (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

  • Require os.path.isfile on the match, so the cache/<key> directory is never selected.
  • Only append the ref if check_in_media(...) returned one (no None in the cell).
  • Collapse a single-attachment message to a bare ref (renders like any other single-media cell); keep a list only for genuine multi-attachment messages.

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

  • Fixture test on a real teleguard_database.db modelling the cache/<key>/<file> layout (inner basename != key) with the cache directories present in files_found: resolves the inner file, skips both directories, never emits None, single attachment → bare ref, missing/text rows → empty.
  • pylint clean (-d C,R); PluginLoader loads 492.
  • Reporter confirmed images now render in both the HTML report and the LAVA Media column, no crash.

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.
@abrignoni abrignoni merged commit beec991 into main Jun 22, 2026
2 checks passed
@abrignoni abrignoni deleted the fix-teleguard-media-lava branch June 22, 2026 02:39
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).
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