Re-adding an existing-but-unsynced account returns 409 before the DB sync, leaving it un-mirrored #50
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found in the high-effort code review of PR #46.
views_api.py:3753— the admin add-account endpoint raises 409 as soon asadd_accountreportsalready_existed, before reaching the libra-DB mirror step at:3761:If an account exists in the Beancount ledger but not in libra's DB — e.g. a prior
sync_single_account_from_beancountfailed (no cross-DB atomicity), or theopenwas added out of band — re-adding it via the UI is the natural recovery action, but the 409 short-circuits the sync. The account stays invisible to the permissions layer with no recovery path through this endpoint.Suggested fix
When the account already exists in the ledger, still run (or fall through to) the DB sync and return a 200/"already existed, synced" rather than a hard 409 — or expose a separate "sync this account" affordance. The 409 should signal "nothing to do," not block reconciliation.
Fixed and shipped in v0.4.0 (PR #46, catalog updated).
39440b7— the endpoint now returns 409 only when the account exists in the ledger and libra's DB; a ledger-only account (prior sync failure / out-of-band open) is synced and returns success instead of being stranded. Covered by a recovery test (create → drop DB row → re-add → synced).