refactor(db): extract DB_AHEAD payload helper (Sourcery follow-up on #65)#66
Conversation
PR #65 follow-up. Sourcery flagged the find-and-slice for the DB_AHEAD payload as duplicated logic between lib.rs and the regression test. One implementation is better. - New `pub fn extract_db_ahead_payload(err: &str) -> Option<&str>` in `db/mod.rs`. Returns `Some(payload)` when the marker is in the string, `None` otherwise. lib.rs and the test now both consume this helper. - Negative-case test added: unrelated errors (sidecar timeout, out-of-disk-space, window builder errors, empty string) must return None — otherwise STARTUP_BLOCKED.txt would get written for unrelated failures and dilute its signal. Tests: Rust 207/207 (was 205), clippy + fmt clean. Five db_ahead* tests now cover the helper end-to-end: - passes on fresh install - passes when DB matches binary - blocks when DB has future migration - extracts even when wrapped - returns None when marker absent Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Guide du réviseurRefactorise la gestion du marqueur DB_AHEAD en extrayant une fonction utilitaire partagée pour analyser la charge utile (payload) à partir des chaînes d'erreur et en mettant à jour à la fois le runtime et les tests pour s'appuyer sur cette implémentation unique, ajoutant ainsi une couverture de régression plus robuste, à la fois positive et négative. Diagramme de séquence pour l’utilitaire d’extraction de la charge utile DB_AHEAD dans la gestion des erreurssequenceDiagram
participant TauriSetup as Tauri_setup
participant DbInit as db_init_pool
participant Extract as db_extract_db_ahead_payload
participant Notice as write_startup_blocked_notice
TauriSetup->>DbInit: init_pool()
DbInit-->>TauriSetup: Err(e) with DB_AHEAD_MARKER
TauriSetup->>Extract: extract_db_ahead_payload(e)
alt marker_present
Extract-->>TauriSetup: Some(payload)
TauriSetup->>Notice: write_startup_blocked_notice(payload)
else marker_absent
Extract-->>TauriSetup: None
TauriSetup-->>TauriSetup: [no STARTUP_BLOCKED.txt written]
end
Modifications au niveau des fichiers
Conseils et commandesInteraction avec Sourcery
Personnaliser votre expérienceAccédez à votre tableau de bord pour :
Obtenir de l’aide
Original review guide in EnglishReviewer's GuideRefactors the DB_AHEAD marker handling by extracting a shared helper function to parse the payload from error strings and updating both runtime and tests to rely on this single implementation, adding stronger positive and negative regression coverage. Sequence diagram for DB_AHEAD payload extraction helper in error handlingsequenceDiagram
participant TauriSetup as Tauri_setup
participant DbInit as db_init_pool
participant Extract as db_extract_db_ahead_payload
participant Notice as write_startup_blocked_notice
TauriSetup->>DbInit: init_pool()
DbInit-->>TauriSetup: Err(e) with DB_AHEAD_MARKER
TauriSetup->>Extract: extract_db_ahead_payload(e)
alt marker_present
Extract-->>TauriSetup: Some(payload)
TauriSetup->>Notice: write_startup_blocked_notice(payload)
else marker_absent
Extract-->>TauriSetup: None
TauriSetup-->>TauriSetup: [no STARTUP_BLOCKED.txt written]
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Salut - j'ai passé en revue tes changements et ils sont excellents !
Sourcery est gratuit pour l'open source - si tu apprécies nos revues, merci d'envisager de les partager ✨
Original comment in English
Hey - I've reviewed your changes and they look great!
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Sourcery feedback on the freshly-merged PR #65
Valid DRY observation: the find-and-slice was duplicated between
lib.rs(runtime) and the regression test. A future tweak (trim whitespace, strip a leading colon, normalize encoding) would need both sites updated.Fix
New
pub fn db::extract_db_ahead_payload(err: &str) -> Option<&str>. ReturnsSome(payload)when the marker is found,Noneotherwise.lib.rs::setupand the regression test both consume it.Tests
db_ahead_payload_extracts_even_when_wrapped. Now exercises the helper end-to-end against 4 wrappings (current, alternative, none, multi-layer).db_ahead_payload_returns_none_when_marker_absent— verifies the helper does NOT match unrelated errors (sidecar timeout, out-of-disk-space, generic Tauri setup errors, empty string). Negative case prevents STARTUP_BLOCKED.txt from being written for failures it wasn't designed to flag, which would dilute the file's signal.Rust 207/207 (was 205), clippy + fmt clean.
When to ship
v0.3.10 just shipped (workflow Release in flight). I'll bundle this into the next tag — either as v0.3.11 alongside other small fixes that accumulate, or as a v0.3.10.1 if we want to keep the polish stream tight. No urgency since the previous PR was already shippable; this is pure code-quality DRY.
🤖 Generated with Claude Code
Summary by Sourcery
Extraire un helper partagé pour analyser les payloads d’erreurs DB_AHEAD et l’intégrer dans la gestion du démarrage au runtime ainsi que dans les tests de régression.
Enhancements:
db::extract_db_ahead_payloadpour centraliser la détection du marqueur DB_AHEAD et l’extraction du payload dans le module base de données.Tests:
Original summary in English
Summary by Sourcery
Extract a shared helper for parsing DB_AHEAD error payloads and wire it through runtime startup handling and regression tests.
Enhancements:
Tests: