← Back to Pull requests

fix(import): refuse empty parsed imports under replace-all (#412) #426

Closed
unknown closed this pull request without merging on Dec 02, 2026 20:41 UTC
View on GitHub
unknown unknown commented on Dec 02, 2026 19:55 UTC
Author

Closes #412

Summary


  • Extracts store-facing import handlers into src/utils/importHandlers.js (executeJsonImport / executeHtmlImport) and wires BookmarkApp.jsx through them.

  • Refuses replaceAll whenever bookmarksToImport.length === 0 (empty JSON arrays, unsafe-URL-only JSON, empty/malformed Netscape HTML, or unsafe-URL-only HTML), showing app.replaceAllEmptyRefused ("error") and never invoking saveAllBookmarks (bulkReplace), appendBookmarks, or clearLastAction.

  • Updates ImportConfirmCard.jsx to show importExport.willReplace ("This will replace your collection with <strong>{count}</strong> bookmark(s).") including 0 while keeping Confirm disabled at count === 0, and adds an explicit effectiveImport.count === 0 guard inside ImportExportContent.jsx#executeImport.

  • Adds handler-level unit tests in src/utils/importHandlers.test.js (JSON empty, JSON unsafe-only, JSON skipExisting: false, HTML empty, HTML unsafe-only, plus valid replace-all runs) and updates src/components/ImportExportContent.test.jsx with zero-count replace-all card coverage.

  • Adds .changeset/import-replace-all-empty-guard.md.
  • Verification


  • npm run format, npx eslint --max-warnings=0 src/utils/importHandlers.js src/utils/importHandlers.test.js, and npm run ci </dev/null passed cleanly (Test Files 139 passed (139), Tests 1679 passed (1679), Chrome MV3 build, chunk laziness check, third-party notices check, version policy check, and Storybook build all succeeded).

  • Claude Sonnet pre-push review completed and all callers of saveAllBookmarks / bulkReplace / initialPendingImport audited (bookmarkUndo.js intentionally passes replaced || [] on undo and remains unaffected).
  • <!-- agent-bot-write: ghw_35a0e83d90cec1dc session=210bdd5e08f0 bot=trueline-antigravity-agent[bot] conversation_id=e99b26b3-53f9-4d7f-8337-fb33257bb240 conversation_id_source=self-reported -->

    Diff: 241 lines (+180 / -61) across 3 files Reviewer: qwts Review duration: 46m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 241 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.328
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #426"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 38.8% (MEDIUM) · Higher = larger blast radius
    38.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.3% · Safe to merge
    15.3%