diff --git a/entity-registry/src/main/java/com/linkedin/metadata/aspect/validation/FieldPathValidator.java b/entity-registry/src/main/java/com/linkedin/metadata/aspect/validation/FieldPathValidator.java index b1fd86bf116bde..47603504dd8a06 100644 --- a/entity-registry/src/main/java/com/linkedin/metadata/aspect/validation/FieldPathValidator.java +++ b/entity-registry/src/main/java/com/linkedin/metadata/aspect/validation/FieldPathValidator.java @@ -36,14 +36,37 @@ public class FieldPathValidator extends AspectPayloadValidator { /** * Prevent any MCP for SchemaMetadata where field ids are duplicated (except for MCPs with {@link - * ChangeType#DELETE}). + * ChangeType#DELETE} and {@link ChangeType#PATCH}, the latter gets handled pre-commit to the DB). */ @Override protected Stream validateProposedAspects( @Nonnull Collection mcpItems, @Nonnull RetrieverContext retrieverContext) { return mcpItems.stream() - .filter(i -> !ChangeType.DELETE.equals(i.getChangeType())) + .filter( + i -> + !ChangeType.DELETE.equals(i.getChangeType()) + && !ChangeType.PATCH.equals(i.getChangeType())) + .filter( + i -> + i.getAspectName().equals(SCHEMA_METADATA_ASPECT_NAME) + || i.getAspectName().equals(EDITABLE_SCHEMA_METADATA_ASPECT_NAME)) + .map( + i -> { + if (i.getAspectName().equals(SCHEMA_METADATA_ASPECT_NAME)) { + return processSchemaMetadataAspect(i); + } else { + return processEditableSchemaMetadataAspect(i); + } + }) + .filter(Objects::nonNull); + } + + @Override + protected Stream validatePreCommitAspects( + @Nonnull Collection changeMCPs, @Nonnull RetrieverContext retrieverContext) { + return changeMCPs.stream() + .filter(i -> ChangeType.PATCH.equals(i.getChangeType())) .filter( i -> i.getAspectName().equals(SCHEMA_METADATA_ASPECT_NAME) @@ -89,10 +112,4 @@ private static AspectValidationException processSchemaMetadataAspect(BatchItem i } return null; } - - @Override - protected Stream validatePreCommitAspects( - @Nonnull Collection changeMCPs, @Nonnull RetrieverContext retrieverContext) { - return Stream.empty(); - } }