Abdulkader Safi

What a code review found that 147 passing tests missed

Private CRM's gap checklist added a Today page and tasks on deals. Then a max-level code review found data leaks, a UTC date bug and a capped count.

5 min read

Share
Code review comments on a pull request next to a green test suite with 147 passing tests

The gap checklist pull request merged with 147 tests passing, clippy clean and type checks green. Then I ran a max-level code review on it. It found a member seeing an admin's deal, tasks missing early in the morning in Kuwait, and a count that quietly stopped at 10.

None of those broke a test. This post covers what the checklist added, what the review found, and how each fix became a test.

The gap checklist

After the agents' feature requests (part 6), a checklist of remaining gaps was left. Pull request #2 built them one commit at a time:

  • A test that fails if any MCP tool name contains delete, remove, archive or destroy (part 3).
  • Unit tests for KWD rounding (part 4).
  • A toast when a board move fails, and Won and Lost columns that start collapsed (part 10).
  • Tasks linked to a deal or a contact (migration 039). The deal page and the contact page each got a Tasks card with a quick add form, and a contact's card also showed tasks on that contact's deals.
  • A Today page, first under Workspace in the sidebar: tasks due today or overdue, open deals gone quiet using each person's quiet setting, the open pipeline per currency, and the last 10 activities on deals the person can see.
  • Small fixes: the sidebar search box matches the other inputs, / redirects to /dashboard, and pages stopped growing wider than the window.

What the review found

The review ran on top of main after the merge. Pull request #3, "Fixes from the code review of PR #2", fixed everything it found.

A member could see an admin's deal

The contact page listed every deal on that contact. If an admin had a deal on a member's contact, the member saw the deal, its tasks, and the owner's full user record. The visibility rule from part 2 was correct. This page just never asked it.

Now a contact page lists only deals the reader can open, and only tasks on those.

Task rows sent too much

Task rows on /tasks, /today and record pages sent the full owner record and the full linked deal or contact, and kept sending them after the reader lost access. Now a task row carries the owner's name and the linked record's title or name, nothing else, and drops the link when the reader can't open that record.

The pattern: the page showed a name, but the props carried the whole record. Inertia props are visible in the page source, so "the UI doesn't show it" isn't protection.

"Today" was the UTC date

Kuwait is UTC+3. Until 03:00 local time the UTC date is still yesterday, so early in the morning tasks due that day were missing. The fix gave users a today() method that uses their timezone, else the company's (part 9 shows the code). Today, Tasks, the deal and contact pages, the pipeline and the dashboard's overdue list all use it. The Today test now freezes time so it can't pass by luck of the hour.

A count that stopped at 10

The Today page's "Gone quiet" count used to stop at 10, so 11 quiet deals or 50 both read as 10. Now it counts every quiet deal, and the list still shows ten.

Smaller findings

  • Anyone who sees every record can now tick or archive another person's task, so a disabled user's leftover tasks can be cleared. Those archived tasks show on that person's Archive page.
  • Quick add on a deal or contact page now says why a task was refused (blank, or over 255 characters). Before, nothing happened.
  • Undated tasks sort last on SQLite and PostgreSQL alike. The two databases put nulls in different places by default.
  • Stage moves on the Today page show in the reader's language (part 8).
  • Won and Lost toggles keep keyboard focus and carry aria-expanded with a label.
  • The Welcome page's shader, images, WGSL plugin and two GPU packages were removed.

Added after the review

Two more changes went into the same pull request:

  1. Foreign keys on task links. Migration 040 clears any link to a deal or contact that doesn't exist, then adds foreign keys that set the link to null if the record is ever deleted. Nothing in the app deletes (part 3), but the database shouldn't depend on that.
  2. "Turn your phone upright." iPhones ignore the manifest's portrait setting, so short touch screens in landscape get a full-screen message (part 10).

Every fix got a test

The suite went from 147 to 153 tests, with a new test for each fix. The browser checks were listed in the pull request too: the quick add error on a deal page, column toggle focus, /tasks, and the sideways phone screen at 844x390 plus its absence upright and on desktop.

One pull request later, the services catalog (part 4) brought it to 158.

What I learned

Tests check what you thought of. A review checks what you didn't. The bugs here had the same shape: a rule that was right in one place and never called in another, or data sent because it was there. I wrote about why this matters more as code gets cheaper in AI made writing code cheap, review is still expensive.

If you take one habit from this series: after every feature that touches who-sees-what, put two owners' records next to each other in a test and check what each one gets back.

Next for Private CRM: invoice pages in the app, built on the invoice rules that already moved into shared actions.

Last updated 4 Dec 2026 · filed under Rust, ai, crm

Every entry on this project

12 build notes, in order

Including the ones where nothing worked. You are on part 12.

Read the series →

FAQ

Frequently asked questions

Why do bugs get past a passing test suite?

Tests check the cases someone thought of. In Private CRM all 147 tests passed while a member could see an admin's deal on a shared contact, because no test put records from two owners on one contact. Reviews find the cases nobody wrote down. Each finding then becomes a test so it stays fixed.

What is the UTC date bug?

Using the server's UTC date as "today" for a user in another timezone. In Kuwait, UTC+3, the UTC date is still yesterday until 03:00 local time, so tasks due today were missing from the Today page early in the morning. Private CRM now computes today from the user's timezone, or the company's if they haven't set one.

What data should an API send for a linked record?

Only what the page shows. Private CRM's task rows used to send the full owner and linked deal or contact records, even after the reader lost access. Now they send the owner's name and the linked record's title or name, and drop the link when the reader can't open that record.

Should nullable foreign keys use ON DELETE SET NULL?

When the child should outlive the parent, yes. Private CRM tasks can link to a deal or contact. A migration cleared any dangling links, then added foreign keys that set the link to null if the record is ever deleted, so the task stays and loses only the link.

Written by

Abdulkader Safi

Software Engineer

Lead engineer at DSRPT, from Lebanon and based in Kuwait. I write about the tools and bugs from real client work, with the numbers I measured.

About me → GitHub LinkedIn

Need this kind of work done on your project?

Start a project →

Keep reading

More from Private CRM: an AI CRM where Claude does the data entry and you make the calls

All 12 entries →