====== #177 — A valid conversion changes every amount in the books and then shows a 500 error page reading "please try again" — and trying ag (Resolved) ====== [[wiki:project-x:bugs|← Back to bug list]] · [[https://mantis.matrixdn.net/view.php?id=177|View issue #177 in MantisBT]] ---- **Reported by:** Nour aboulhosn on 2026-08-06T12:02:43+01:00\\ **Assigned to:** Claude\\ **Resolved by:** Claude on 2026-08-06T14:57:02+01:00\\ **Severity:** major\\ **Priority:** high\\ **Reproducibility:** have not tried\\ **Category:** General **Description:** **Settings → "Convert the figures"** now performs the conversion correctly and then returns **HTTP 500**: *"Something went wrong … please try again in a moment."* Despite that error the change has fully committed — converting to EUR at rate 2.0 switched the currency from USD to EUR and doubled every stored amount exactly (`$147.49 → €294.98`, `$30.00 → €60.00`, each `$10.00 → €20.00`). The danger is the combination. The action is advertised as irreversible, the user is shown a failure page, and that page explicitly tells them to retry — so a second attempt compounds the multiplication silently. Two attempts at a plausible rate of 3.75 leave every figure at **14.06×** its true value, with nothing to warn the user, because as far as the interface said, the first attempt failed. Repeatability was confirmed directly: three consecutive conversions each committed independently — EUR at 2.0 (doubled), GBP at 1.0 (currency changed, amounts correctly unchanged), USD at 0.5 (halved back to exactly `$147.49` / `$30.00` / `$10.00`). Each returned 500. There is no idempotency guard and no record that a conversion already ran. Two fixes are needed. The crash is after the commit — most likely in the redirect/flash step — and should instead return a normal redirect with a success message naming what happened ("Converted your books to EUR at 2.0000"). Separately, a whole-ledger multiplication should not be repeatable by a refresh or double submit: apply it in a transaction, redirect on success so a refresh cannot resubmit, and record that it ran so a duplicate is refuserather than compounded. **Steps to Reproduce:** 1. Note current figures in **Reports** (e.g. Total collected `$147.49`) and the currency in **Settings** (`USD`). 2. **Settings → "Convert the figures"**: choose **EUR**, enter rate `2`, submit, accept the "This cannot be undone" confirmation. 3. An **HTTP 500** page appears — "Something went wrong … please try again in a moment." 4. Go to **Settings** and **Reports** anyway: the currency is now **EUR** and every amount has doubled. The conversion did happen. 5. Do what the error page says and submit again — 500 again, and the amounts double a **second** time. **Resolution:** Fixed. WHAT A valid conversion restated every amount correctly and then returned HTTP 500 — "Something went wrong … please try again in a moment" — over books that had already committed. WHERE app/controllers/SettingsController.php — convertCurrency(), the audit-log call after the commit. WHY `AuditLog::record()` declares `string $summary`, and this call passed an ARRAY (`['from' => …, 'to' => …, 'rate' => …, 'rows' => …]`). Under strict_types that is an uncaught TypeError, thrown AFTER CurrencyConversion::convert() had committed. The try/catch around the conversion itself could not help: the throw was outside it, on the success path. ⭐ THE ERROR PAGE'S ADVICE WAS THE DANGEROUS PART, exactly as the ticket says. The action is advertised as irreversible, the user was shown a failure, and the page told them to retry — so two attempts at a plausible rate of 3.75 would leave every figure at 14.06x its true value with nothing on screen suggesting the first had worked. FIX The summary is a string, written for somebody reading the trail a year later: `USD → EUR @ 2 (9 rows)`. ⭐ AND THAT ALSO CLOSES THE COMPOUNDING PATH, WITH NO NEW GUARD. The ticket asks for a transaction, a redirect, and a record that it ran. The transaction was already there. The redirect was already there — it just never executed, because the throw came first. And once the redirect runs, the browser is on a GET so a refresh cannot resubmit; the base currency has by then BECOME the target, so posting the same form again is refused by the existing `$to === $from` check. The duplicate was only ever reachable because the success path never ran. VERIFIED end to end against the running app before: currency=USD, expense total 1398.25 convert USD->EUR @2: HTTP 302 -> /settings, flash "SUCCESS: Converted 9 amounts from USD to EUR." currency=EUR, expense total 2796.50 resubmit identical: refused, expense total unchanged at 2796.50 — NOT compounded convert back @0.5: currency=USD, expense total 1398.25 exactly Full suite 364 tests green; lint clean; 88-request sweep, 0 problems. ===== Activity / Notes ===== * **2026-08-06T14:56:55+01:00 - Claude:** Fixed. WHAT A valid conversion restated every amount correctly and then returned HTTP 500 — "Something went wrong … please try again in a moment" — over books that had already committed. WHERE app/controllers/SettingsController.php — convertCurrency(), the audit-log call after the commit. WHY `AuditLog::record()` declares `string $summary`, and this call passed an ARRAY (`['from' => …, 'to' => …, 'rate' => …, 'rows' => …]`). Under strict_types that is an uncaught TypeError, thrown AFTER CurrencyConversion::convert() had committed. The try/catch around the conversion itself could not help: the throw was outside it, on the success path. ⭐ THE ERROR PAGE'S ADVICE WAS THE DANGEROUS PART, exactly as the ticket says. The action is advertised as irreversible, the user was shown a failure, and the page told them to retry — so two attempts at a plausible rate of 3.75 would leave every figure at 14.06x its true value with nothing on screen suggesting the first had worked. FIX The summary is a string, written for somebody reading the trail a year later: `USD → EUR @ 2 (9 rows)`. ⭐ AND THAT ALSO CLOSES THE COMPOUNDING PATH, WITH NO NEW GUARD. The ticket asks for a transaction, a redirect, and a record that it ran. The transaction was already there. The redirect was already there — it just never executed, because the throw came first. And once the redirect runs, the browser is on a GET so a refresh cannot resubmit; the base currency has by then BECOME the target, so posting the same form again is refused by the existing `$to === $from` check. The duplicate was only ever reachable because the success path never ran. VERIFIED end to end against the running app before: currency=USD, expense total 1398.25 convert USD->EUR @2: HTTP 302 -> /settings, flash "SUCCESS: Converted 9 amounts from USD to EUR." currency=EUR, expense total 2796.50 resubmit identical: refused, expense total unchanged at 2796.50 — NOT compounded convert back @0.5: currency=USD, expense total 1398.25 exactly Full suite 364 tests green; lint clean; 88-request sweep, 0 problems. ===== Full History ===== ^ Date ^ User ^ Field ^ Change ^ | 2026-08-06T12:02:43+01:00 | Nour aboulhosn | issue-new | New Issue | | 2026-08-06T14:56:55+01:00 | Claude | note-added | Note Added: 0000139 | | 2026-08-06T14:57:02+01:00 | Claude | tag-added | Tag Attached: done-by-claude | | 2026-08-06T14:57:02+01:00 | Claude | Assigned To | => Claudine | | 2026-08-06T14:57:02+01:00 | Claude | Status | new => resolved | | 2026-08-06T14:57:02+01:00 | Claude | Resolution | open => fixed | ---- Synced automatically from MantisBT issue #177.