Skip to content

fix: UI: Validate and prevent duplicate metadata keys for commits#9916

Merged
zubron merged 1 commit into
treeverse:masterfrom
majiayu000:fix-9729-ui-validate-and-prevent-duplicate-metada
Jan 9, 2026
Merged

fix: UI: Validate and prevent duplicate metadata keys for commits#9916
zubron merged 1 commit into
treeverse:masterfrom
majiayu000:fix-9729-ui-validate-and-prevent-duplicate-metada

Conversation

@majiayu000

Copy link
Copy Markdown
Contributor

Summary

This PR fixes #9729

Changes

  • webui/src/lib/components/repository/metadata.jsx
  • webui/src/lib/components/repository/metadataHelpers.js
  • webui/src/lib/components/repository/metadataHelpers.test.js

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>
@CLAassistant

CLAassistant commented Dec 29, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added the area/UI Improvements or additions to UI label Dec 29, 2025
@zubron zubron self-requested a review January 9, 2026 17:13

@zubron zubron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@zubron zubron merged commit 05027a2 into treeverse:master Jan 9, 2026
83 of 84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/UI Improvements or additions to UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI: Validate and prevent duplicate metadata keys for commits

3 participants