Skip to content

Commit

Permalink
Fix open-metadata#13982: Fix userFQN encoding while creating mentions (
Browse files Browse the repository at this point in the history
…open-metadata#14496)

* Fix open-metadata#13982: Fix userFQN encoding while creating mentions

* quote only teams or users
  • Loading branch information
harshach authored Dec 26, 2023
1 parent e98ae8a commit 4b7f4f4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions bootstrap/sql/migrations/native/1.2.4/mysql/schemaChanges.sql
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
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 {
Expand Down Expand Up @@ -167,18 +169,19 @@ public static EntityLink parse(String link) {
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);
}
Expand Down

0 comments on commit 4b7f4f4

Please sign in to comment.