WL-0MM8V5SF11MGNQNM: Audit db.import() call sites and add safety docs#791
Merged
rgardler-msft merged 1 commit intomainfrom Mar 2, 2026
Merged
Conversation
- Add detailed JSDoc to db.import() in database.ts warning it is destructive (clears all items) and recommending upsertItems() for partial updates - Add inline SAFETY comments at all 5 remaining call sites: sync.ts, import.ts, init.ts, api.ts, index.ts - All sites confirmed safe: each passes a full merged or complete set - No additional unsafe callers discovered
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
db.import()insrc/database.tswarning it is destructive (clears all items before inserting) and recommendingupsertItems()for partial updates.// SAFETY:comments at all 5 remainingdb.import()call sites documenting why each usage is safe.Audit results
All 5 remaining
db.import()call sites pass complete item sets — no unsafe callers found:src/commands/sync.tssrc/commands/import.tssrc/commands/init.tssrc/api.tssrc/index.tsThe 4 previously-unsafe call sites in
src/commands/github.tswere already fixed in PR #789 (replaced withupsertItems()).Context
Final task (Feature 4 of 4) for critical data-loss bug WL-0MM8RQOC902W3LM5:
db.upsertItems()API (PR WL-0MM8V4UPC02YMFXK: Add non-destructive db.upsertItems() API #788, merged)db.import()withdb.upsertItems()in GitHub flows (PR WL-0MM8V55PV1Q32K7D: Fix destructive db.import() in GitHub flows #789, merged)db.import()call sites and add safety docs (this PR)Test results