Skip to content

Commit

Permalink
fix: urlencode slash in urns too
Browse files Browse the repository at this point in the history
Urns for datasources with datasetNameDelimiter: "/" was not encoded
correctly, resulting in REST calls not returning any data when querying
with the urn.
  • Loading branch information
daha committed Apr 1, 2022
1 parent 66defee commit 1329123
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions metadata-ingestion/src/datahub/cli/cli_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def batch_get_ids(
url = gms_host + endpoint
ids_to_get = []
for id in ids:
ids_to_get.append(urllib.parse.quote(id))
ids_to_get.append(urllib.parse.quote(id, safe=""))

response = session.get(
f"{url}?ids=List({','.join(ids_to_get)})",
Expand Down Expand Up @@ -515,7 +515,7 @@ def get_entity(
# we assume the urn is already encoded
encoded_urn: str = urn
elif urn.startswith("urn:"):
encoded_urn = urllib.parse.quote(urn)
encoded_urn = urllib.parse.quote(urn, safe="")
else:
raise Exception(
f"urn {urn} does not seem to be a valid raw (starts with urn:) or encoded urn (starts with urn%3A)"
Expand Down
2 changes: 1 addition & 1 deletion metadata-ingestion/src/datahub/cli/timeline_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def get_timeline(
# we assume the urn is already encoded
encoded_urn: str = urn
elif urn.startswith("urn:"):
encoded_urn = urllib.parse.quote(urn)
encoded_urn = urllib.parse.quote(urn, safe="")
else:
raise Exception(
f"urn {urn} does not seem to be a valid raw (starts with urn:) or encoded urn (starts with urn%3A)"
Expand Down
2 changes: 1 addition & 1 deletion metadata-ingestion/src/datahub/ingestion/graph/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def get_aspect_v2(
:rtype: Optional[Aspect]
:raises HttpError: if the HTTP response is not a 200 or a 404
"""
url = f"{self._gms_server}/aspects/{urllib.parse.quote(entity_urn)}?aspect={aspect}&version=0"
url = f"""{self._gms_server}/aspects/{urllib.parse.quote(entity_urn, safe="")}?aspect={aspect}&version=0"""
response = self._session.get(url)
if response.status_code == 404:
# not found
Expand Down

0 comments on commit 1329123

Please sign in to comment.