Fix #13982: Fix userFQN encoding while creating mentions (#14496)

* Fix #13982: Fix userFQN encoding while creating mentions

* quote only teams or users
This commit is contained in:
Sriharsha Chintalapani 2023-12-25 17:28:13 -08:00 committed by GitHub
parent e98ae8aa2a
commit 4b7f4f43d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 5 deletions

View File

@ -0,0 +1,3 @@
update field_relationship fr INNER JOIN user_entity ue on fr.fromFQN=ue.name
set fr.fromFQNHASH=MD5(JSON_UNQUOTE(JSON_EXTRACT(ue.json, '$.fullyQualifiedName'))),
fr.fromFQN=JSON_UNQUOTE(JSON_EXTRACT(ue.json, '$.fullyQualifiedName')) where fr.fromType='user';

View File

@ -0,0 +1,3 @@
update field_relationship fr
set fromFQNHASH=MD5(ue.json->>'fullyQualifiedName'),
fromFQN=ue.json->>'fullyQualifiedName' from user_entity ue where fr.fromType='user' and fr.fromFQN=ue.name;

View File

@ -23,6 +23,8 @@ import java.util.regex.Pattern;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.openmetadata.service.Entity;
import org.openmetadata.service.util.FullyQualifiedName;
@Slf4j
public final class MessageParser {
@ -167,18 +169,19 @@ public final class MessageParser {
EntityLink entityLink = null;
while (matcher.find()) {
if (entityLink == null) {
String entityType = matcher.group(1);
String entityFQN = matcher.group(2);
if (entityFQN == null) {
throw new IllegalArgumentException(
"Invalid Entity Link. Entity FQN is missing in " + link);
}
if (entityType.equalsIgnoreCase(Entity.USER)
|| entityType.equalsIgnoreCase(Entity.TEAM)) {
entityFQN = FullyQualifiedName.quoteName(entityFQN);
}
entityLink =
new EntityLink(
matcher.group(1),
entityFQN,
matcher.group(4),
matcher.group(6),
matcher.group(8));
entityType, entityFQN, matcher.group(4), matcher.group(6), matcher.group(8));
} else {
throw new IllegalArgumentException("Unexpected multiple entity links in " + link);
}