Skip to content

Switch to Standard UUID representation #5034

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

Closed
wants to merge 2 commits into from
Closed

Conversation

christophstrobl
Copy link
Member

Closes: #3932

@@ -291,7 +291,7 @@ protected MongoClientSettings computeClientSetting() {
applySettings(builder::retryWrites, computeSettingsValue(defaultSettings.getRetryWrites(),
mongoClientSettings.getRetryWrites(), connectionString.getRetryWritesValue()));
applySettings(builder::uuidRepresentation,
computeSettingsValue(null, mongoClientSettings.getUuidRepresentation(), UuidRepresentation.JAVA_LEGACY));
computeSettingsValue(null, mongoClientSettings.getUuidRepresentation(), UuidRepresentation.STANDARD));
Copy link
Member

Choose a reason for hiding this comment

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

Why do we use here constants and not connectionString.getUuidRepresentation()?

Copy link
Member Author

Choose a reason for hiding this comment

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

guess we're missing a test here - let's align with the above and add the test for it

@mp911de mp911de added this to the 5.0 M5 (2025.1.0) milestone Aug 4, 2025
@mp911de mp911de added the type: enhancement A general enhancement label Aug 4, 2025
@@ -226,7 +226,7 @@ protected boolean autoIndexCreation() {
protected MongoClientSettings mongoClientSettings() {

MongoClientSettings.Builder builder = MongoClientSettings.builder();
builder.uuidRepresentation(UuidRepresentation.JAVA_LEGACY);
builder.uuidRepresentation(UuidRepresentation.STANDARD);
Copy link
Contributor

Choose a reason for hiding this comment

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

The GH Issue says

Turn defaulting off and enforce an explicit choice from the user.

To do that, shouldn't this be changed to UuidRepresentation.UNSPECIFIED?

The risk of changing from JAVA_LEGACY to STANDARD is that applications with existing data can end up with a mix of UUID representations for the same field in the same collection, and then have a very difficult time querying their data.

Copy link
Member

@mp911de mp911de Aug 7, 2025

Choose a reason for hiding this comment

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

I filed #5037 to track the further progress. Removing defaulting and failing early (instead of a delayed failure during save/query) would be an ideal signal to require additional configuration from the application. Removing defaults is going to create quite some inconvenience during upgrade.

Another alternative could be leaving defaults as-is but issuing warn logging if the default value is implicitly (i.e. not explicitly configured) used.

Also, I updated the original ticket description.

@mp911de mp911de changed the title Switch to Standard UUID representation. Switch to Standard UUID representation Aug 7, 2025
mp911de pushed a commit that referenced this pull request Aug 7, 2025
mp911de added a commit that referenced this pull request Aug 7, 2025
Align ConnectionString defaulting. Fix broken Javadoc links.

See: #3932
Original pull request: #5034
@mp911de mp911de closed this Aug 7, 2025
@mp911de mp911de deleted the issue/3932 branch August 7, 2025 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update default UUID representation to Standard (BSON binary subtype 4)
3 participants