Skip to content

Prevent duplicate env entries - #138

Merged
tofran merged 4 commits into
mainfrom
prevent-duplicated-env-entries
Oct 20, 2026
Merged

tofran merged 4 commits into
mainfrom
prevent-duplicated-env-entries

Conversation

@tofran

@tofran tofran commented Oct 20, 2026

Copy link
Copy Markdown
Member

No description provided.

Copilot AI balanced review requested due to automatic review settings October 20, 2026 16:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Validation blocks repairing existing duplicates and can discard unsaved edits; duplicate diagnostics also report incorrect line numbers.

3 open issues
What changed in this PR

Prevents duplicate environment keys across 1Password, Fly, and local secrets workflows.

Changes:

  • Detects duplicate keys and reports their source and line numbers.
  • Adds validation to secrets workflows.
  • Adds return-type overloads for file reading.
File Description
onepassword_secrets/​utils.py Adds file-reading type annotations and overloads.
onepassword_secrets/​envs.py Detects duplicates and adds source-aware errors.
onepassword_secrets/​commands.py Validates secrets during import, edit, pull, push, and creation.

Review effort: Balanced

Comment thread onepassword_secrets/commands.py Outdated
item_id = get_1password_env_file_item_id(f"fly:{app_id}", vault=vault)

current_raw_secrets = get_envs_from_1password(item_id, vault=vault)
get_secrets_from_envs(current_raw_secrets, source="the 1Password item")
Comment thread onepassword_secrets/commands.py Resolved
Comment thread onepassword_secrets/envs.py Resolved
Copilot AI balanced review requested due to automatic review settings October 20, 2026 17:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Strict validation of existing contents prevents repairing duplicates through editing or replacing them with valid secrets.

4 open issues

Review effort: Balanced

Comment thread onepassword_secrets/envs.py Outdated
Comment on lines +22 to +24
duplicate_keys = get_duplicate_keys_from_envs(input)

if len(duplicate_keys) > 0:
tofran and others added 2 commits October 20, 2026 19:11
Pull, push, create and fly import abort when the local env file or the
1Password item defines a key more than once. Fly edit warns about
duplicates in the 1Password item and opens the editor so they can be
fixed, but refuses to save while duplicates remain.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Fly edit now offers to reopen the editor on the same file when the saved
contents fail validation, instead of aborting and deleting the edits.
Duplicate key errors also report the key's real line, as the parser
attaches leading blank lines to the following binding.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 20, 2026 18:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No blocking issues were identified in the validation, repair, or synchronization changes.

2 open issues
2 resolved since last review

Review effort: Balanced

@tofran
tofran merged commit 0bc3e31 into main Oct 20, 2026
3 checks passed
@tofran
tofran deleted the prevent-duplicated-env-entries branch October 20, 2026 21:19
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.

2 participants