Skip to content

Commit

Permalink
Do not enforce owner validation in update call if table owner has not…
Browse files Browse the repository at this point in the history
… changed (#534)
  • Loading branch information
swaranga-netflix authored Feb 20, 2023
1 parent a9c816f commit 1142f21
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,11 @@ public TableDto updateAndReturn(final QualifiedName name, final TableDto tableDt
// we do ownership validation and enforcement only if table owner is set in the dto
// because if it is null, we do not update the owner in the existing metadata record
if (tableDto.getTableOwner().isPresent()) {
ownerValidationService.enforceOwnerValidation("updateTable", name, tableDto);
// only if the owner is different from the previous, we run the enforcement
// for backwards compatibility
if (!tableDto.getTableOwner().get().equals(oldTable.getTableOwner().orElse(null))) {
ownerValidationService.enforceOwnerValidation("updateTable", name, tableDto);
}
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@ class TableServiceImplSpec extends Specification {

then:
1 * ownerValidationService.enforceOwnerValidation("updateTable", name, updatedTableDto)

when:
tableDto.setDefinitionMetadata(toObjectNode("{\"owner\":{\"userId\":\"ssarma\"}}"))
service.updateAndReturn(name, updatedTableDto)

then:
0 * ownerValidationService.enforceOwnerValidation(_, _, _)
}

def "Will not throw on Successful Table Update with Failed Get"() {
Expand Down

0 comments on commit 1142f21

Please sign in to comment.