fix: UI: Validate and prevent duplicate metadata keys for commits#9916
Merged
zubron merged 1 commit intoJan 9, 2026
Merged
Conversation
Add frontend validation to prevent duplicate metadata keys in commits. JavaScript objects silently drop duplicate keys, causing data loss. This change validates keys as users enter them and shows "Key already exists" error for duplicate entries. Changes: - Add isDuplicateKey helper to detect duplicates (case-insensitive after trim) - Update isInvalidKey to check for duplicates - Update getFieldError to return appropriate error message - Update MetadataFields component to pass index and all fields for validation - Add comprehensive tests for duplicate key detection Fixes treeverse#9729 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: majiayu000 <1835304752@qq.com>
zubron
approved these changes
Jan 9, 2026
zubron
left a comment
Contributor
There was a problem hiding this comment.
Nice! Thanks for fixing this and including tests 👍
One minor UX note: when you're focused in an input that is a duplicate which hasn't been validated, and then click "Add field", it requires two clicks (first click blurs the current field and shows the error, the second then adds the field). This is fine for now, we can improve the interaction behaviour in a follow-up PR.
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
This PR fixes #9729
Changes
webui/src/lib/components/repository/metadata.jsxwebui/src/lib/components/repository/metadataHelpers.jswebui/src/lib/components/repository/metadataHelpers.test.js