sinks/wealthfolio: treat duplicates as success in import-summary check
The IMAP cronjob re-processes the full mailbox window on every run, so on steady-state runs all activities come back tagged duplicate=N. The existing logic raises ImportValidationError whenever imported_n < total_n, which makes the cron exit 1 (and the Job is reported FAILED) even though the data path is healthy. Treat (imported + duplicates) as "accounted for". Only raise when rows go missing entirely (silently dropped / validation rejected). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
2fb1fbbdd8
commit
0ab069349f
1 changed files with 7 additions and 3 deletions
|
|
@ -247,10 +247,14 @@ class WealthfolioSink:
|
|||
if summary is not None:
|
||||
imported_n = int(summary.get("imported", 0))
|
||||
total_n = int(summary.get("total", len(valid_rows)))
|
||||
if imported_n < total_n:
|
||||
dupes = int(summary.get("duplicates", 0))
|
||||
skipped = int(summary.get("skipped", 0))
|
||||
# Duplicates are expected on every re-run (the cron re-processes the
|
||||
# full IMAP window each night) — treat (imported + duplicates) as
|
||||
# accounted-for. Only fail if something was genuinely lost.
|
||||
accounted = imported_n + dupes
|
||||
if accounted < total_n:
|
||||
err_msg = summary.get("errorMessage") or "no errorMessage"
|
||||
skipped = int(summary.get("skipped", 0))
|
||||
dupes = int(summary.get("duplicates", 0))
|
||||
raise ImportValidationError(f"Wealthfolio /import persisted {imported_n}/{total_n} "
|
||||
f"(skipped={skipped} duplicates={dupes}). "
|
||||
f"errorMessage: {err_msg}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue