Skip to content

fix: prevent duplicate dotenv key mass-deletion from keys view#5

Draft
cursor[bot] wants to merge 1 commit intomainfrom
cursor/-bc-79a75ca0-0351-4f30-b12e-c696301eefd3-86a2
Draft

fix: prevent duplicate dotenv key mass-deletion from keys view#5
cursor[bot] wants to merge 1 commit intomainfrom
cursor/-bc-79a75ca0-0351-4f30-b12e-c696301eefd3-86a2

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor bot commented Apr 3, 2026

Summary

  • Fixes a critical data-loss bug in dotenv key management UI where removing one duplicate key deleted all lines with that key.
  • Adds an index-aware removal helper so the UI removes exactly the selected row.
  • Adds regression tests covering duplicate-key removal behavior.

Bug and impact

In the dotenv Keys view, clicking Remove on a key used key-based deletion (removeDotenvKey) that removes every matching key line. For files with duplicate keys (common during merges or staged rotations), one click could silently delete multiple values and persist them on save.

Root cause

The UI rendered duplicate entries distinctly by row index, but removal was implemented by key name only, collapsing all duplicates into one deletion operation.

Fix

  • Added removeDotenvEntryAt(content, entryIndex) in src/lib/dotenv-parse.ts.
  • Updated file-workspace.tsx to pass the displayed row index to removal and call removeDotenvEntryAt.
  • Kept legacy removeDotenvKey unchanged for existing callers.

Validation

  • Added src/lib/dotenv-parse.test.ts with regression coverage for duplicate keys and preservation of comments/blank lines.
  • Ran: npm test -- src/lib/dotenv-parse.test.ts (passes).
Open in Web View Automation 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant