Repository navigation
Prevent duplicate env entries - #138
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 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
| 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 on lines
+22
to
+24
| duplicate_keys = get_duplicate_keys_from_envs(input) | ||
|
|
||
| if len(duplicate_keys) > 0: |
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>
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.

No description provided.