Document regex invariants & surface broken contact bindings #64

Merged
parkerhdavis merged 2 commits from backend-reliability-2 into main 2026-05-21 12:42:21 -06:00
parkerhdavis commented 2026-05-21 11:23:07 -06:00 (Migrated from github.com)

Summary

  • #3 from scan — Audit .unwrap() calls in docx_ops.rs. Tracing each unwrap showed they're all safe by construction (guarded by surrounding if let Some(...), is_none() short-circuits, explicit len() checks, or the regex match guaranteeing the substring exists). Converted each to .expect("<invariant>") so a future refactor breaking the assumption produces a useful panic message instead of a bare unwrap() on None. Also replaced one best.is_none() || pos < best.unwrap().0 with best.is_none_or(|b| pos < b.0). Pure cleanup, no behavior change.
  • #4 from scan — Surface broken contact bindings. resolve_contact_variables used to silently drop bindings that pointed at deleted contacts: the role's variables stayed blank and the user had no signal. Changed the Tauri command to return Result<Vec<String>, String> carrying one warning per broken binding, and added a resolveContactVariables helper on the frontend that toasts each warning (8s warning toast). All five existing call sites now go through the helper.

Test plan

  • make typecheck
  • make lint
  • make test — 93/93 passing
  • Manual: bind a role to a contact, then delete the contact and reopen the client — confirm warning toast appears and "Has {role}" becomes false
## Summary - **#3 from scan — Audit `.unwrap()` calls in `docx_ops.rs`.** Tracing each unwrap showed they're all safe by construction (guarded by surrounding `if let Some(...)`, `is_none()` short-circuits, explicit `len()` checks, or the regex match guaranteeing the substring exists). Converted each to `.expect("<invariant>")` so a future refactor breaking the assumption produces a useful panic message instead of a bare `unwrap() on None`. Also replaced one `best.is_none() || pos < best.unwrap().0` with `best.is_none_or(|b| pos < b.0)`. Pure cleanup, no behavior change. - **#4 from scan — Surface broken contact bindings.** `resolve_contact_variables` used to silently drop bindings that pointed at deleted contacts: the role's variables stayed blank and the user had no signal. Changed the Tauri command to return `Result<Vec<String>, String>` carrying one warning per broken binding, and added a `resolveContactVariables` helper on the frontend that toasts each warning (8s warning toast). All five existing call sites now go through the helper. ## Test plan - [x] `make typecheck` - [x] `make lint` - [x] `make test` — 93/93 passing - [ ] Manual: bind a role to a contact, then delete the contact and reopen the client — confirm warning toast appears and "Has {role}" becomes false
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
parker/lily!64
No description provided.