fava_client.add_account 500s on newer Fava: "Trying to read a non-source file" for accounts/users.beancount #43

Open
opened 2026-06-12 18:40:12 +00:00 by padreug · 0 comments
Owner

Symptom

FavaClient.add_account (fava_client.py:~1624) fails against current pip-released Fava:

GET /libra-test/api/source?filename=.../accounts/users.beancount
500 {"error":"Trying to read a non-source file at '/tmp/.../accounts/users.beancount'"}

Surfaced by test_balances_api.py::test_credit_balance_subtracts_from_net when running the suite against a fresh uv pip install fava (2026-06-12). Pre-existing — reproduces identically on pre-15d9910 code, so not related to the entry-identity fix.

Likely cause

Newer Fava restricts /api/source to files that are actual sources of the loaded ledger (reachable via include). add_account writes to accounts/users.beancount, which the test ledger (and possibly some deployed ledgers) doesn't include, so Fava refuses to serve/edit it.

To investigate

  • Which Fava version introduced the restriction; which version production runs.
  • Whether the fix is (a) ensure the main ledger always includes accounts/users.beancount before writing to it, or (b) route account creation through PUT /api/add_entries (Open directive) instead of source-file editing.
  • Production impact check: does account auto-creation (get_or_create_user_account) break on a Fava upgrade?

🤖 Generated with Claude Code

## Symptom `FavaClient.add_account` (fava_client.py:~1624) fails against current pip-released Fava: ``` GET /libra-test/api/source?filename=.../accounts/users.beancount 500 {"error":"Trying to read a non-source file at '/tmp/.../accounts/users.beancount'"} ``` Surfaced by `test_balances_api.py::test_credit_balance_subtracts_from_net` when running the suite against a fresh `uv pip install fava` (2026-06-12). **Pre-existing** — reproduces identically on pre-15d9910 code, so not related to the entry-identity fix. ## Likely cause Newer Fava restricts `/api/source` to files that are actual sources of the loaded ledger (reachable via `include`). `add_account` writes to `accounts/users.beancount`, which the test ledger (and possibly some deployed ledgers) doesn't `include`, so Fava refuses to serve/edit it. ## To investigate - Which Fava version introduced the restriction; which version production runs. - Whether the fix is (a) ensure the main ledger always `include`s `accounts/users.beancount` before writing to it, or (b) route account creation through `PUT /api/add_entries` (Open directive) instead of source-file editing. - Production impact check: does account auto-creation (`get_or_create_user_account`) break on a Fava upgrade? 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aiolabs/libra#43
No description provided.