Skip to content

Commit fa16633

Browse files
authored
Do not apply rules when creating an artifact with no content (#4955)
* Do not apply rules when creating an artifact with no content * Format code
1 parent 7411043 commit fa16633

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

app/src/main/java/io/apicurio/registry/rest/v3/GroupsResourceImpl.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,8 @@ public CreateArtifactResponse createArtifact(String groupId, IfArtifactExists if
740740
if (data.getFirstVersion().getBranches() == null) {
741741
data.getFirstVersion().setBranches(Collections.emptyList());
742742
}
743+
} else {
744+
requireParameter("body.artifactType", data.getArtifactType());
743745
}
744746

745747
if (!ArtifactIdValidator.isGroupIdAllowed(groupId)) {
@@ -797,8 +799,11 @@ public CreateArtifactResponse createArtifact(String groupId, IfArtifactExists if
797799
final Map<String, TypedContent> resolvedReferences = storage.resolveReferences(referencesAsDtos);
798800

799801
// Apply any configured rules
800-
rulesService.applyRules(new GroupId(groupId).getRawGroupIdWithNull(), artifactId, artifactType,
801-
typedContent, RuleApplicationType.CREATE, references, resolvedReferences);
802+
if (content != null) {
803+
rulesService.applyRules(new GroupId(groupId).getRawGroupIdWithNull(), artifactId,
804+
artifactType, typedContent, RuleApplicationType.CREATE, references,
805+
resolvedReferences);
806+
}
802807

803808
// Create the artifact (with optional first version)
804809
EditableArtifactMetaDataDto artifactMetaData = EditableArtifactMetaDataDto.builder()

0 commit comments

Comments
 (0)