Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 27, 2025

Adds support for the {UUID} placeholder to resolve an entry's UUID in hexadecimal format, enabling seamless migration from KeePass 2.x to KeePassXC. Also implements support for nested placeholders in references like {REF:U@I:{UUID}}.

Problem

Users migrating from KeePass 2.x to KeePassXC often have entries containing references like {REF:U@I:{UUID}} that rely on the {UUID} placeholder. Without this placeholder, users must manually replace hundreds of references with actual UUID values, which is time-consuming and error-prone.

Solution

This PR implements the {UUID} placeholder that resolves to the entry's UUID in hexadecimal format (e.g., 1829072CFF3F5E48839E7E3E173B52CB), matching KeePass 2.x behavior. Additionally, it enables nested placeholder resolution within references, allowing complex self-referencing patterns.

Usage Examples

{UUID}                     → 1829072CFF3F5E48839E7E3E173B52CB
{REF:U@I:{UUID}}          → References username of this entry by UUID
{REF:P@I:{UUID}}          → References password of this entry by UUID
Entry ID: {UUID}          → Entry ID: 1829072CFF3F5E48839E7E3E173B52CB

Implementation

  • Added Uuid to PlaceholderType enum in Entry.h
  • Added {UUID} to the placeholders map in Entry.cpp
  • Added resolution case that calls existing uuidToHex() method
  • Enhanced reference regex in EntryAttributes.cpp to handle nested braces in SearchText
  • Added placeholder resolution in reference SearchText processing for nested placeholders
  • Supports case-insensitive usage ({UUID}, {uuid}, {Uuid})
  • Works in all entry fields (title, username, password, notes, URL, custom attributes)

Testing

  • Added comprehensive test testResolveUuidPlaceholder() covering direct resolution, case insensitivity, and mixed text scenarios
  • Added advanced test for {REF:U@I:{UUID}} nested placeholder usage in custom attributes
  • All existing tests pass (17/17 for TestEntry)
  • Code formatted and translations updated per project standards

This change provides a minimal, surgical solution that maintains full backward compatibility while enabling smooth migration from KeePass 2.x for users with existing UUID-based references, including complex self-referencing patterns.

Fixes #12509

Original prompt

This section details on the original issue you should resolve

<issue_title>Implementing {UUID} as a reference</issue_title>
<issue_description>### Have you searched for an existing feature request?

  • Yes, I tried searching

Brief Summary

It would be great to introduce a new reference {UUID} which would help people migrating from KeePass to KeePassXC.

Example

{UUID} = 1829072CFF3F5E48839E7E3E173B52CB

Context

I am switching from KeePass 2.x to KeePassXC and have A LOT of entries in which I reference to the entry itself.
For example: {REF:U@I:{UUID}}

Workaround: replacing my placeholder {UUID} with the actual UUID. There is also no easy way to retrieve and copy the UUID but to open the entry, selecting the properties and copying the UUID then switching back to advanced and replacing it.

I know there is a possibility to directly use {TITLE} instead of {REF:T@I:{UUID}} but again, for people migrating with hundreds of entries this is not a really good solution.

Alternative would be a search-and-replace function to replace those references.</issue_description>

<agent_instructions>Placeholders such as {TITLE} and {UUID} are defined in src/core/entry.cpp</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #12509

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Implementing {UUID} as a reference Implement {UUID} placeholder for entry UUID resolution Sep 27, 2025
Copilot AI requested a review from droidmonkey September 27, 2025 13:22
@codecov
Copy link

codecov bot commented Sep 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.38%. Comparing base (fd2a729) to head (0c99f6e).
⚠️ Report is 25 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #12511      +/-   ##
===========================================
+ Coverage    64.35%   64.38%   +0.03%     
===========================================
  Files          378      378              
  Lines        39715    39719       +4     
===========================================
+ Hits         25557    25571      +14     
+ Misses       14158    14148      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@droidmonkey
Copy link
Member

@copilot Add a test for an advanced attribute being set to {REF:U@I:{UUID}} with the expected return value of the same entry's username value.

…n references

- Added test case for advanced attribute {REF:U@I:{UUID}} resolving to entry's own username
- Fixed regex in EntryAttributes::matchReference to handle nested braces like {UUID}
- Added placeholder resolution in search text for reference placeholders
- All existing tests continue to pass

Co-authored-by: droidmonkey <[email protected]>
Copy link
Contributor Author

Copilot AI commented Sep 27, 2025

@copilot Add a test for an advanced attribute being set to {REF:U@I:{UUID}} with the expected return value of the same entry's username value.

Added the requested test case for an advanced attribute set to {REF:U@I:{UUID}} that correctly resolves to the entry's own username value.

The implementation required fixing the reference regex to handle nested braces (like {UUID} inside references) and adding placeholder resolution in the SearchText part of references.

Test now validates that {REF:U@I:{UUID}} in a custom attribute resolves to the expected username "TestUser". All existing tests continue to pass.

Commit: 6d3aa98

Copilot AI changed the title Implement {UUID} placeholder for entry UUID resolution Implement {UUID} placeholder for entry UUID resolution with nested reference support Sep 27, 2025
@droidmonkey droidmonkey marked this pull request as ready for review September 27, 2025 17:00
Copilot AI review requested due to automatic review settings September 27, 2025 17:00
@droidmonkey droidmonkey added this to the v2.7.11 milestone Sep 27, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Implements the {UUID} placeholder to resolve an entry's UUID in hexadecimal format, enabling smooth migration from KeePass 2.x to KeePassXC. The implementation also adds support for nested placeholders in references like {REF:U@I:{UUID}} through enhanced reference resolution.

  • Added {UUID} placeholder that resolves to entry UUID in hex format
  • Enhanced reference regex to handle nested braces in search text
  • Added placeholder resolution within reference search text for nested placeholder support

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/core/Entry.h Added Uuid to PlaceholderType enum
src/core/Entry.cpp Added UUID placeholder resolution and nested placeholder support in references
src/core/EntryAttributes.cpp Updated reference regex to handle nested braces
tests/TestEntry.h Added test method declaration
tests/TestEntry.cpp Added comprehensive tests for UUID placeholder functionality

@droidmonkey droidmonkey merged commit 5736c63 into develop Sep 27, 2025
11 checks passed
@droidmonkey droidmonkey deleted the copilot/fix-4c953389-a6db-4e96-85e4-5411a8c5228f branch September 27, 2025 23:08
pull bot pushed a commit to gburkhow/keepassxc that referenced this pull request Sep 27, 2025
…boot#12511)

* Closes keepassxreboot#12509
* Implement the {UUID} placeholder
* Implement nested placeholder de-referencing when resolving entry references to support a reference like {REF:U@I:{UUID}} which is equivalent to {USERNAME} placeholder.

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: droidmonkey <[email protected]>
Co-authored-by: Jonathan White <[email protected]>
pull bot pushed a commit to surkin/keepassxc that referenced this pull request Sep 28, 2025
…boot#12511)

* Closes keepassxreboot#12509
* Implement the {UUID} placeholder
* Implement nested placeholder de-referencing when resolving entry references to support a reference like {REF:U@I:{UUID}} which is equivalent to {USERNAME} placeholder.

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: droidmonkey <[email protected]>
Co-authored-by: Jonathan White <[email protected]>
@droidmonkey droidmonkey added the pr: backported Pull request backported to previous release label Oct 25, 2025
droidmonkey added a commit that referenced this pull request Oct 26, 2025
* Closes #12509
* Implement the {UUID} placeholder
* Implement nested placeholder de-referencing when resolving entry references to support a reference like {REF:U@I:{UUID}} which is equivalent to {USERNAME} placeholder.

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: droidmonkey <[email protected]>
Co-authored-by: Jonathan White <[email protected]>
@michaelk83
Copy link

@droidmonkey For transparency, you forgot to add the AI-assisted label to this PR and to #12314, #12204, and #12199.

(There were also a couple more where no code was generated.)

@droidmonkey droidmonkey added the pr: ai-assisted Pull request contains significant contributions by generative AI label Nov 8, 2025
@droidmonkey
Copy link
Member

Done

dragonekii pushed a commit to dragonekii/keepassxc-custom that referenced this pull request Dec 8, 2025
Release 2.7.11 (2025-11-23)

- Add image, HTML, Markdown preview, and text editing support to inline attachment viewer [keepassxreboot#12085, keepassxreboot#12244, keepassxreboot#12654]
- Add database merge confirmation dialog [keepassxreboot#10173]
- Add option to auto-generate a password for new entries [keepassxreboot#12593]
- Add support for group sync in KeeShare [keepassxreboot#11593]
- Add {UUID} placeholder for use in references [keepassxreboot#12511]
- Add “Wait for Enter” search option [keepassxreboot#12263]
- Add keyboard shortcut to “Jump to Group” from search results [keepassxreboot#12225]
- Add predefined search for TOTP entries [keepassxreboot#12199]
- Add confirmation when closing database via ESC key [keepassxreboot#11963]
- Add support for escaping placeholder expressions [keepassxreboot#11904]
- Reduce tab indentation width in notes fields [keepassxreboot#11919]
- Cap default Argon2 parallelism when creating a new database [keepassxreboot#11853]
- Database lock after inactivity now enabled by default and set to 900 seconds [keepassxreboot#12689, keepassxreboot#12609]
- Copying TOTP now opens setup dialog if none is configured for entry [keepassxreboot#12584]
- Make double click action configurable [keepassxreboot#12322]
- Remove unused “Last Accessed” from GUI [keepassxreboot#12602]
- Auto-Type: Add more granular confirmation settings [keepassxreboot#12370]
- Auto-Type: Add URL typing preset and add copy options to menu [keepassxreboot#12341]
- Browser: Do not allow sites automatically if entry added from browser extension [keepassxreboot#12413]
- Browser: Add options to restrict exposed groups [keepassxreboot#9852, keepassxreboot#12119]
- Bitwarden Import: Add support for timestamps and password history [keepassxreboot#12588]
- macOS: Add Liquid Glass icon [keepassxreboot#12642]
- macOS: Remove theme-based menubar icon toggle [keepassxreboot#12685]
- macOS: Add Window and Help menus [keepassxreboot#12357]
- Windows: Add option to add KeePassXC to PATH during installation [keepassxreboot#12171]

- Fix window geometry not being restored properly when KeePassXC starts in tray [keepassxreboot#12683]
- Fix potential database truncation when using direct write save method with YubiKeys [keepassxreboot#11841]
- Fix issue with database backup saving [keepassxreboot#11874]
- Fix UI lockups during startup with multiple tabs [keepassxreboot#12053]
- Fix keyboard shortcuts when menubar is hidden [keepassxreboot#12431]
- Fix clipboard being cleared on exit even if no password was copied [keepassxreboot#12603]
- Fix single-instance detection when username contains invalid filename characters [keepassxreboot#12559]
- Fix “Search Wait for Enter” setting not being save [keepassxreboot#12614]
- Fix hotkey accelerators not being escaped properly on database tabs [keepassxreboot#12630]
- Fix confusing error if user cancels out of key file edit dialog [keepassxreboot#12639]
- Fix issues with saved searches and “Press Enter to Search” option [keepassxreboot#12314]
- Fix URL wildcard matching [keepassxreboot#12257]
- Fix TOTP visibility on unlock and settings change [keepassxreboot#12220]
- Fix KeeShare entries with reference attributes not updating [keepassxreboot#11809]
- Fix sort order not being maintained when toggling filters in database reports [keepassxreboot#11849]
- Fix several UI font and layout issues [keepassxreboot#11967,  keepassxreboot#12102]
- Prevent mouse wheel scroll on edit username field [keepassxreboot#12398]
- Improve base translation consistency [keepassxreboot#12432]
- Improve inactivity timer [keepassxreboot#12246]
- Documentation improvements [keepassxreboot#12373, keepassxreboot#12506]
- Browser: Fix ordering of clientDataJSON in Passkey response object [keepassxreboot#12120]
- Browser: Fix URL matching for additional URLs [keepassxreboot#12196]
- Browser: Fix group settings inheritance [keepassxreboot#12368]
- Browser: Allow read-only native messaging config files [keepassxreboot#12236]
- Browser: Optimise entry iteration in browser access control dialog [keepassxreboot#11817]
- Browser: Fix “Do not ask permission for HTTP Basic Auth” option [keepassxreboot#11871]
- Browser: Fix native messaging path for Tor Browser launcher on Linux [keepassxreboot#12005]
- Auto-Type: Fix empty window behaviour [keepassxreboot#12622]
- Auto-Type: Take delays into account when typing TOTP [keepassxreboot#12691]
- SSH Agent: Fix out-of-memory crash with malformed SSH keys [keepassxreboot#12606]
- CSV Import: Fix modified and creation time import [keepassxreboot#12379]
- CSV Import: Fix duplication of root groups on import [keepassxreboot#12240]
- Proton Pass Import: Fix email addresses not being imported when no username set [keepassxreboot#11888]
- macOS: Fix secure input getting stuck [keepassxreboot#11928]
- Windows: Prevent launch as SYSTEM user from MSI installer [keepassxreboot#12705]
- Windows: Remove broken check for MSVC Redistributable from MSI installer [keepassxreboot#11950]
- Linux: Fix startup delay due to StartupNotify setting in desktop file [keepassxreboot#12306]
- Linux: Fix memory initialisation when --pw-stdin is used with a pipe [keepassxreboot#12050]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: Reference/Placeholders pr: ai-assisted Pull request contains significant contributions by generative AI pr: backported Pull request backported to previous release pr: new feature Pull request adds a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implementing {UUID} as a reference

3 participants