Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CustomData serialization breaks KeepassXC #76

Closed
1fexd opened this issue Jan 19, 2025 · 5 comments
Closed

CustomData serialization breaks KeepassXC #76

1fexd opened this issue Jan 19, 2025 · 5 comments

Comments

@1fexd
Copy link

1fexd commented Jan 19, 2025

It appears creating a database and saving it breaks KeepassXC which errors with the following error message: Error while reading the database: Missing custom data key or value

After some troubleshooting, and tracking down the relevant KeepassXC line, the issue seems to be that Jackson serializes the database and includes an empty <Item>:

<CustomData>
  <Item/>
</CustomData>
@jorabin
Copy link
Owner

jorabin commented Jan 19, 2025

Hi

Can you please say which version of KeePassJava2 you are using?

Also, you are saying that you create a database in KeePassJava2 and save it, before trying to load in KeePassXC?

thanks

@1fexd
Copy link
Author

1fexd commented Jan 21, 2025

I'm using 2.2.3 - yes I'm creating a database using KeePassJava2, which opens fine in regular KeePass, but KeepassXC fails.
Managed to disable this by setting JacksonSerializationDatabase using

mapper.disable(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS);

not sure if this is desirable

@jorabin
Copy link
Owner

jorabin commented Jan 21, 2025

Thanks for the confirmation.

The problem is related to CustomData being serialised with an empty item within Meta. CustomData in Group or Entry doesn't have this problem.

I have a fix that does very similar to what you have tried, only it removes all empty elements:

        mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);

which I have pushed to develop and also 2.2.4-SNAPSHOT release.

Cheers

@jorabin
Copy link
Owner

jorabin commented Jan 23, 2025

If you can confirm this solves the problem then we can close.

@1fexd
Copy link
Author

1fexd commented Jan 23, 2025

Yes, it works now - thanks!

@1fexd 1fexd closed this as completed Jan 23, 2025
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

No branches or pull requests

2 participants