Skip to main content

Bug Report: POST /v2/habits/{id}/logs/undo fails to delete auto-generated logs created by "Mark habit as completed"

Summary:
Whenever a habit is marked as completed—either via the API endpoint POST /v2/habits/{id}/logs/complete or via the "Mark as complete" action in the web/mobile app—Habitify automatically generates a log entry for the amount needed to satisfy the goal (either the full goal amount, or the remaining amount if partial logs already exist). However, calling the Undo habit logs for a day API endpoint (POST /v2/habits/{id}/logs/undo) completely ignores this completion-generated log, leaving it intact and keeping the habit marked as completed (or partially completed).

Steps to Reproduce:

  1. Select a habit with a daily goal (e.g., Brush teeth with a goal of 2 reps) that has no logs for the target date.

  2. Mark the habit as completed via POST /v2/habits/{id}/logs/complete (or click "Mark as complete" in the app). Habitify marks the habit as "completed" and creates a single log entry with a value equal to the full goal (2).

  3. Call POST /v2/habits/{id}/logs/undo for that targetDate.

  4. Inspect the habit via GET /v2/habits/{id}/logs, the statistics endpoint, or the Habitify app.

(Note: If a partial manual log—e.g., 1 rep—was added prior to Step 2, /logs/undo deletes only the manual log while leaving the completion-generated log intact, reverting the habit to "inprogress" with 1/2 reps.)

Expected Behavior:
POST /v2/habits/{id}/logs/undo should clear all logs and completion statuses for the specified targetDate—including any log entry auto-generated by the completion action—resetting the habit to 0 progress.

Actual Behavior:
POST /v2/habits/{id}/logs/undo has no effect on the completion-generated log. The log entry remains extant in the habit's log history, and the habit continues to register as "completed" (or "inprogress" if prior manual logs were removed).

Additional Context & Workaround:

  • This behavior occurs consistently regardless of whether completion was triggered via the API (POST /logs/complete) or through the Habitify app UI.

  • Manually clicking "Clear logs" in the app UI successfully deletes the completion-generated log, and calling DELETE /v2/habits/{id}/logs/{logId} with that specific log's ID also removes it properly—confirming the issue is isolated to the /logs/undo endpoint skipping logs created by the completion action.

    PS: I used AI to format/rephrase the bug report according to my rambling description of the observed behavior, but I (a real human bean) have extensively tested this particular use case, and the generated bug report is accurate.

No comments yet

Be the first to share your thoughts.