-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix: bypass shouldCompare for Topic schema field updates #26735
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
e60de22
05ec2fe
999a81f
3f47d29
b99710b
7006505
aad62f9
b0d18e2
d871673
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -662,13 +662,23 @@ public void entitySpecificUpdate(boolean consolidatingChanges) { | |||||||||||||||||
| ? null | ||||||||||||||||||
| : original.getMessageSchema().getSchemaType(), | ||||||||||||||||||
| updated.getMessageSchema().getSchemaType()); | ||||||||||||||||||
| updateSchemaFields( | ||||||||||||||||||
| "messageSchema.schemaFields", | ||||||||||||||||||
| original.getMessageSchema() == null | ||||||||||||||||||
| ? new ArrayList<>() | ||||||||||||||||||
| : listOrEmpty(original.getMessageSchema().getSchemaFields()), | ||||||||||||||||||
| listOrEmpty(updated.getMessageSchema().getSchemaFields()), | ||||||||||||||||||
| EntityUtil.schemaFieldMatch); | ||||||||||||||||||
| // Temporarily disable shouldCompare for nested schema field updates. | ||||||||||||||||||
| // The field names from getSchemaField() start with "schemaFields." which | ||||||||||||||||||
| // doesn't match the patchedField "messageSchema", causing recordChange | ||||||||||||||||||
| // to silently skip the update. | ||||||||||||||||||
|
||||||||||||||||||
| // The field names from getSchemaField() start with "schemaFields." which | |
| // doesn't match the patchedField "messageSchema", causing recordChange | |
| // to silently skip the update. | |
| // EntityUtil.getSchemaField(...) (used by schemaFieldMatch) produces field | |
| // paths starting with "schemaFields.", which do not match the patchedField | |
| // "messageSchema", causing recordChange() to silently skip the update. | |
| // TODO: Remove this workaround once schema field paths are aligned with | |
| // messageSchema patching. |
Outdated
Copilot
AI
Mar 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting patchedFields to null temporarily disables all shouldCompare filtering inside updateSchemaFields, not just the nested schema-field change tracking. This can cause PATCH requests that touch messageSchema (e.g., schemaText/schemaType) to also record/propagate changes from schema fields that were not intended to be part of the patch. Consider a narrower approach: temporarily extend the patched field set to include the schemaFields prefix (or make EntityUtil.getSchemaField(...) return paths under messageSchema.schemaFields) so only schema-field tracking is unblocked without disabling filtering globally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EntityUpdateris a public inner class, so adding a Lombok@GettermakesgetPatchedFields()a new public API and exposes the mutableSetdirectly. To avoid widening the surface area and accidental external mutation, consider generating aprotected(or package-private) getter, or returning an unmodifiable copy, and keep the setter visibility as narrow as possible.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot can you review again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All three concerns from the original review have been addressed in commits
7006505andd871673:EntityRepository.java–@Getterremoved; replaced with a hand-writtenprotectedgetter that returnsSet.copyOf(patchedFields), preventing external mutation and keeping the accessor non-public.TopicRepository.java(logic) – Instead of nullingpatchedFields, the fix now temporarily extends the set with"schemaFields", so only schema field tracking is unblocked without disablingshouldComparefor all other fields.EntityUtil.getSchemaField(...)as the precise source of the path mismatch, with aTODOpointing to the long-term proper fix.new java.util.HashSet<>()to use the already-importedHashSet(d871673).