A success response tells you the server accepted your request. It doesn’t tell you the data is now what you meant. Validation can quietly adjust a value, a rules engine can overwrite it a moment later, and a timeout can leave you not knowing whether anything happened at all.
I run a self-hosted finance app called Mizan on top of Firefly III, and it changes real records, so I wanted it to treat “accepted” and “done” as different things. This is how it does that, and a gap I found in my own claim.
What happens when you change a category
When you move a transaction to a different category, the app does this, in order:
- Validate first. The category must exist, notes have a length limit, transfers don’t take a category, and split transactions are refused outright. A partial update to one split can drop the others, so the app doesn’t risk it.
- Take a write lock, so two edits can’t interleave.
- Send the change, with the ledger’s own rules engine and webhooks switched off for that request, so nothing else can alter the value behind my back.
- Read the transaction back and compare the field to what I intended. If the category or note isn’t what I sent, the app raises an error (“Firefly didn’t keep the new category”) instead of reporting success.
- Only then refresh its snapshot and write the audit entry.
The audit log records ids and category names, never descriptions, amounts or note text. A test asserts exactly that: it makes an edit with a distinctive note, then checks that the note, the description and the amount appear nowhere in the log.
Reads are retried, writes are not
The HTTP client treats the two differently. A read gets up to three attempts with a growing pause, so a restart or a slow query doesn’t break a page. A write gets one. If a write times out, I can’t tell whether it applied, and trying again blind is how a change gets applied twice. For a write, the honest answer to a timeout is “I don’t know, check”, and the read-back is what lets the next screen show the truth.
A check you’ve never seen fail isn’t a check
The test I trust most is the one with a server that lies. It wraps the read so that after the app sends a change, Firefly appears to accept it but returns the old value. The test passes only if the app raises an error. Without it, a read-back that was silently broken would look identical to one that works.
The gap I found
When I sat down to write this, I checked my own README against the code. It said Mizan verifies each change it writes back. That was only half true.
Editing a single transaction was read back. Creating a rule, replacing an old one, and re-filing past transactions in bulk were not, one by one. After those, the app refreshed its snapshot from the ledger, so the screen showed the real state, but nothing confirmed each change took.
I wanted to see what that meant in practice, so I made the second of six bulk writes fail on the fake ledger I use for tests. The app showed an error, as it should. But one transaction had already been re-filed, and there was no audit entry, because the log was written at the end and the error skipped it. A partial change that leaves no trace is exactly what an audit log exists to prevent.
Mizan was written with an AI coding assistant, so checking that the code does what the documentation says is my job.
What changed
- A new rule is read back and must carry exactly the trigger and action I sent. If it doesn’t, it is deleted and nothing is re-filed.
- The order matters. The earlier rule for the same text is removed only after the new one is verified. Before, a failure in between could leave me with no rule at all. The group is then re-read to confirm one rule remains for that text.
- Bulk re-filing is counted. The affected transactions are re-read and reported as updated or failed, and the app shows the failed count.
- The audit entry is written even when a run fails part-way, with counts, the category and the length of the match text, never descriptions or amounts.
I then ran the same failure again. With the second of six writes failing, the app now reports five updated and one failed, and the audit entry says the same. The test suite passes, with tests for a failing bulk write, a rule saved with different content, and the same choice made twice.
Two writes are still not read back: the rule group created on first use, and deleting an empty account, where Firefly answers with no body to check. I’ve written that down next to the code, instead of a claim that everything is verified. The live demo on this site runs the release with the fix.
What I took from it
Writing down how a system protects itself is a good way to find where it doesn’t. The claim felt true because the design was true for the main path. The bulk path was just the part I hadn’t looked at since I wrote it.