From 8b3064ffab46222eba07d0ee1e01128dfb68f700 Mon Sep 17 00:00:00 2001 From: Jan Novak Date: Thu, 7 May 2026 23:06:34 +0200 Subject: [PATCH] fix(go): default CacheDir to `tmp/go` to avoid Python collision Previously both backends defaulted to `CacheDir=tmp` and used the same cache keys (`attendance_regular`, `attendance_juniors`, `payments_transactions`, `exceptions_dict`) but stored different shapes: Python caches post-processed view-model tuples (e.g. `(members, sorted_months)`), Go caches raw sheet rows. Whichever backend wrote last poisoned the cache for the other, producing `ValueError: too many values to unpack (expected 2, got 68)` on Python's /adults after the Go side populated the file with 68 raw CSV rows. This breaks the M5.4 `make parity` workflow that requires both backends running side-by-side. Fix: change Go's default to `tmp/go` so the two cache trees never overlap. `CACHE_DIR` env var override still works. `os.MkdirAll` already handles creating the new subdirectory on first write. Recovery for users with poisoned `tmp/`: hit /flush-cache on the Python side once after pulling, then restart the Go server. Co-Authored-By: Claude Opus 4.7 --- CHANGELOG.md | 6 ++++++ go/internal/config/config.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3684f8..7b24900 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 2026-05-07 23:05 CEST — fix(go): default CacheDir to `tmp/go` to avoid Python collision + +- `go/internal/config/config.go`: `CacheDir` default changed from `tmp` to `tmp/go`. Override via `CACHE_DIR` env var still works. +- Why: both backends used `tmp/_cache.json` with the same keys (`attendance_regular`, `attendance_juniors`, `payments_transactions`, `exceptions_dict`) but different shapes — Python caches post-processed view-model tuples, Go caches raw rows. Whichever wrote last poisoned the cache; running both in parallel produced `ValueError: too many values to unpack (expected 2, got 68)` on Python's `/adults` after the Go server populated `attendance_regular_cache.json` with raw CSV rows. +- After upgrading: stop the Go server, hit `/flush-cache` on the Python side once (rewrites `tmp/*.json` with correct shapes), then restart `make web-go` — it will use `tmp/go/` going forward. Required for the M5.4 `make parity` workflow which assumes both backends run side-by-side. + ## 2026-05-07 22:37 CEST — feat(py): M5.3 — Python /api/* shadow endpoints - `app.py`: four new JSON routes (`/api/version`, `/api/adults`, `/api/juniors`, `/api/payments`) mirroring the Go `/api/*` handlers; `_unwrap_view_model_for_api()` helper expands pre-serialised JSON strings and renames `month_labels_json` → `month_labels`, `raw_payments_json` → `raw_payments` to match Go wire contract. diff --git a/go/internal/config/config.go b/go/internal/config/config.go index 40815ca..b9d5a11 100644 --- a/go/internal/config/config.go +++ b/go/internal/config/config.go @@ -50,7 +50,7 @@ func Load() Config { return Config{ CredentialsPath: env("CREDENTIALS_PATH", ".secret/fuj-management-bot-credentials.json"), BankAccount: env("BANK_ACCOUNT", "CZ8520100000002800359168"), - CacheDir: env("CACHE_DIR", "tmp"), + CacheDir: env("CACHE_DIR", "tmp/go"), CacheTTL: envDuration("CACHE_TTL_SECONDS", 300), CacheAPICheckTTL: envDuration("CACHE_API_CHECK_TTL_SECONDS", 300), DriveTimeout: envDuration("DRIVE_TIMEOUT_SECONDS", 10),