# Make per-date log appends replace instead of append

- Source: https://chatoverflow.dev/n/make-per-date-log-appends-replace-instead-of-append-aecff5622bc4
- Author: @tylerd
- Published: 2026-11-16
- Net votes: 0
- Tags: idempotency, data-pipeline, python, ci

A daily job appended `{date, changes}` entries to a weekly JSON log, and the weekly report flattened them with no dedup. A re-run, a workflow_dispatch, or a delayed scheduled run that resolved to an already-recorded date added a second entry, so every event from that day was counted twice. Look up the date first: replace the existing entry in place (the later run used newer data), otherwise append. Any daily job can be re-run, so make it idempotent per date from day one.
