Post

Fixing the First-of-the-Month Revenue Ledger Bug and Auditing 121 App Mappings

Why revenue-ledger's report.py exited on December 1 when current-month finalized data was empty, how falling back to the latest available month fixed it, and verifying zero unmapped apps across 52 Toss mini-apps and 69 Unity LevelPlay properties.

Fixing the First-of-the-Month Revenue Ledger Bug and Auditing 121 App Mappings

한국어로 읽기 매월 1일마다 터지는 수익 장부(revenue-ledger) 리포트 버그와 전수 정합성 검증

On the morning of December 1, running my automated revenue ledger update failed at the final reporting step. Because I had recently wired in Unity LevelPlay, I initially suspected the new integration—but it turned out to be a classic first-of-the-month boundary bug in the existing script.

1. Why the report script crashed only on the 1st of the month

The bug came from how finalized dates collided with the default month filter:

  1. On 2026-12-01, both Toss and LevelPlay had finalized entries in the ledger only through yesterday (2026-11-30).
  2. Running the report generator without arguments defaulted to the current month (2026-12), found zero rows, and exited immediately (sys.exit).
  3. That prevented execution from ever reaching the trailing 14-day revenue summary.

The fix: When no month argument is passed and the current month has no rows yet, the script now falls back automatically to the latest month present in the ledger (2026-11). Re-running it cleanly generated the monthly report and the 14-day summary (79,089 KRW Toss + 5,037 KRW Play = 84,126 KRW total for Nov 17–30).

2. Auditing 52 Toss apps and 69 LevelPlay properties

While inspecting the pipeline, I also verified that no newly launched apps were silently dropped:

  • Apps in Toss (52 apps): Full per-app query check confirmed zero missing apps.
  • Unity LevelPlay (69 app configs):
    • The LevelPlay fetcher queries the account-wide /mediation/applications/v6/stats endpoint rather than looping per app, so new apps can’t be skipped at fetch time.
    • Checked all 69 Android LevelPlay configurations against our alias mapping and confirmed 69/69 mapped (0 unmapped).
    • Cross-checking Nov 28–30 (0 new, 97 updated, 0 unmapped warnings) matched 2,046 impressions / $0.55 (~734 KRW) to the won.

Whenever a pipeline ingests through yesterday while a report defaults to the current month, it will trip on the 1st of every month. Adding a simple fallback keeps January 1 quiet as well.

This post is licensed under CC BY 4.0 by the author.