fix(verify): per-contact context in output, drop noisy duplicate-stanza-id warning #115
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/verify-per-contact-context"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Follow-up to the flat-file backend (#94) — three issues with
/history verifyoutput that surfaced on real-world history.1. Flatfile output didn't identify which contact
Every issue was reported as
history.log:NNN — ...regardless of contact. With many contacts inflatlog/<account>/, the user has no way to tell whichhistory.logthe message refers to.Fix:
_verify_contact_dirnow reconstructs the contact JID from the directory name (reversing_at_→@) and uses<contact>/history.logas the basename for every issue from that contact.2. Duplicate stanza-id was reported as WARNING
Older clients (Pidgin, Adium, early Profanity) reuse client-generated stanza-ids across distinct messages. On a long history this floods
/history verifywith dozens-to-hundreds of false positives.Fix: demoted to
log_debug— kept for diagnostics in the log file, removed from verify output. Duplicate archive-id stays at WARNING since XEP-0359 server-generated stanza-ids are required to be unique and a collision is a genuine integrity defect.3. SQLite timestamp-ordering false positives across conversations
The query joined adjacent rows by
B.id = A.id + 1without filtering by conversation pair. With overlapping conversations (alice and bob active simultaneously), adjacent SQL rows belong to different contacts — their timestamps legitimately go out of order, but the verify reported every such pair asTimestamp out of order.Fix: query now joins on matching
from_jid/to_jidand uses aNOT EXISTSsubquery to ensure B is the actually-next row in the same conversation. Both timestamp-ordering and broken-LMC-reference messages also includefrom_jid↔to_jidfor context.Test plan
/history verifyon a flatfile with 5+ contacts — every issue line names the contact~/.local/share/profanity/logs/profanity.log/history switch sqlite && /history verifyon a db with multiple parallel conversations — no spuriousTimestamp out of orderbetween cross-contact adjacent rowsfrom↔toJID pair in the messageplease address the issues pointed out in the review and use
make format@@ -306,0 +311,4 @@// own history.log, so the bare filename is ambiguous).auto_gchar gchar* dir_name = g_path_get_basename(cdir_path);char* dir_unescaped = str_replace(dir_name, "_at_", "@");auto_gchar gchar* basename_owned = g_strdup_printf("%s/history.log",It's not an accurate path. Just avoid using /history.log suffix (preferred) or do not unescape the path.
The only two valid ways:
@@ -306,0 +313,4 @@char* dir_unescaped = str_replace(dir_name, "_at_", "@");auto_gchar gchar* basename_owned = g_strdup_printf("%s/history.log",dir_unescaped ? dir_unescaped : dir_name);free(dir_unescaped);we could use
auto_charinsteadb89f688d70to1aaa382d5eLGTM