Skip to content

Harden media-list None handling in FairEmail, SamsungNotes, gmailIMAPEmails#859

Merged
abrignoni merged 1 commit into
mainfrom
harden-media-list-none
Jun 22, 2026
Merged

Harden media-list None handling in FairEmail, SamsungNotes, gmailIMAPEmails#859
abrignoni merged 1 commit into
mainfrom
harden-media-list-none

Conversation

@abrignoni

Copy link
Copy Markdown
Owner

Hardens three more LAVA media columns against the same None-in-a-media-list crash just fixed for Teleguard - Messages (#858).

Root cause
check_in_media(path, name) returns None when path does not resolve to a checked-in file in the current artifact's files_found — e.g. the loose match landed on a directory, or the file is missing. That None was appended straight into a media-typed list column. lava_insert_sqlite_data json.dumps's a list cell, so it serialized to e.g. ["validref", null]; the LAVA viewer parses the array, hits the null, shows a red broken-media marker and crashes (black screen) on hover. The HTML path (get_data_list_with_media) silently skips unresolved refs, so this only reproduced in LAVA.

Fix (per artifact, mirroring #858)

  • Capture the ref first and append only when truthy — no None ever lands in the media list.
  • 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 (a list only for genuine multi-attachment cells, '' when none resolve), so single-media cells render like every other artifact.
  • No change to which files are matched.

Files

  • scripts/artifacts/FairEmail.py('Attachments','media') and ('Content','media') columns. Also replaces the stray 0 sentinel previously written into the Attachments media cell when a message had no attachments.
  • scripts/artifacts/SamsungNotes.py('Media','media') column.
  • scripts/artifacts/gmailIMAPEmails.py('Attachments','media') column (both the received .db_att and sent .attachment match paths).

Verification

  • py_compile clean on all three.
  • pylint -d C,R → 10.00/10 (only the expected E0401 import-errors, ignored).
  • PluginLoader() loads 492 plugins — identical to main, no module dropped, no load warnings for the three modules.

…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 #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).
@abrignoni abrignoni merged commit a8ba5ef into main Jun 22, 2026
2 checks passed
@abrignoni abrignoni deleted the harden-media-list-none branch June 22, 2026 02:55
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