Return a few days after finishing. Close the earlier lessons and use your own notes only after a first attempt from memory.
Four boundary bugs
This copy of the project has four deliberately broken rules. The case table
runs repository operations on fresh fixtures and reports four findings.
Fix the implementation in lib/domain.js and lib/repository.js, not the
checks in lib/review-checks.js.
npm install and npm run dev. Hint 1: the idea
The four findings are about searching, validating a title, what leaves the server, and editing. Before changing anything, write for each one an input that shows the bug and what the correct result would be.
Hint 2: a first step
Read the four failing checks' names in the table. Then compare three places
with the Study Library lesson's code: validateDraft and publicItem in
lib/domain.js, and list and edit in lib/repository.js. Each holds one
bug, except domain.js, which holds two.
The four bugs
| Bug | Why it's wrong | Fix | Day |
|---|---|---|---|
list filters with row.title.includes(q) | Searching read misses Read about server boundaries: the search is case-sensitive. | Compare row.title.toLowerCase() with q.toLowerCase(). | 1 |
validateDraft uses input.title untrimmed and has no blank check | A title of spaces is saved, and spaces around a title count towards 60. | const title = input.title.trim(); then reject !title. | 2 |
publicItem returns { ...row } | ownerId and tenantId leave the server, and any column added later will too: a denylist by accident. | Return only id, title and version. | 1 |
edit has no version check | An edit from a stale page silently overwrites someone's newer save: a lost update. | if (row.version !== version) return { ok: false, code: "conflict" }; before writing. | 4 |
The owner scoping (canWrite) is still correct in this copy; a fix that
touches it is fixing the wrong thing. The exercise is complete when the four
findings disappear and the checks in lib/review-checks.js are unchanged.
Retrieval questions
- Which values come from a caller, and where is identity established?
- Which fields may leave the server, even for an authorized reader?
- What must remain unchanged after a rejected mutation?
- What makes a version check atomic with the write?
- Which cache lifetime or scope could return another caller's data?
- What can a pure rule test prove that a browser check cannot, and vice versa?
- Which evidence must come from a real Next.js build or database?
- What would you change before offering the practice app to multiple users?
If any answer is vague, redo that day's checkpoint without the solution. Completion is a useful record of practice, not evidence of mastery by itself.
Completion is saved in this browser only. It does not measure mastery.