Fix Fava API endpoint for getting entry context

Use GET /api/context instead of GET /api/source_slice. Fava's API
naming convention means source_slice only supports PUT and DELETE,
while context is the correct endpoint for reading entry data.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Patrick Mulligan 2026-01-02 18:23:18 +01:00
parent f8af54f90b
commit 69ce1d9601

View file

@ -10,7 +10,9 @@ Fava provides a REST API for:
- Querying balances (GET /api/query) - Querying balances (GET /api/query)
- Balance sheets (GET /api/balance_sheet) - Balance sheets (GET /api/balance_sheet)
- Account reports (GET /api/account_report) - Account reports (GET /api/account_report)
- Updating/deleting entries (PUT/DELETE /api/source_slice) - Getting entry context (GET /api/context)
- Updating entries (PUT /api/source_slice)
- Deleting entries (DELETE /api/source_slice)
See: https://github.com/beancount/fava/blob/main/src/fava/json_api.py See: https://github.com/beancount/fava/blob/main/src/fava/json_api.py
""" """
@ -1098,7 +1100,8 @@ class FavaClient:
""" """
Get entry source text and sha256sum for editing. Get entry source text and sha256sum for editing.
Uses /source_slice endpoint which returns the editable source. Uses /context endpoint which returns the editable source slice.
Note: Fava's API uses get_context for reading, put_source_slice for writing.
Args: Args:
entry_hash: Entry hash from get_journal_entries() entry_hash: Entry hash from get_journal_entries()
@ -1117,7 +1120,7 @@ class FavaClient:
try: try:
async with httpx.AsyncClient(timeout=self.timeout) as client: async with httpx.AsyncClient(timeout=self.timeout) as client:
response = await client.get( response = await client.get(
f"{self.base_url}/source_slice", f"{self.base_url}/context",
params={"entry_hash": entry_hash} params={"entry_hash": entry_hash}
) )
response.raise_for_status() response.raise_for_status()