From 3b519924e84d34be3582349f71d6ca58959d0c33 Mon Sep 17 00:00:00 2001 From: Harshal Sheth Date: Thu, 23 Mar 2023 10:34:11 +0530 Subject: [PATCH] fix(cli): protect against timeseries get_aspects (#7665) --- .github/workflows/check-datahub-jars.yml | 1 + metadata-ingestion/src/datahub/ingestion/graph/client.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/check-datahub-jars.yml b/.github/workflows/check-datahub-jars.yml index 7af888f34c..7db9543ade 100644 --- a/.github/workflows/check-datahub-jars.yml +++ b/.github/workflows/check-datahub-jars.yml @@ -25,6 +25,7 @@ concurrency: jobs: check_jars: strategy: + max-parallel: 1 fail-fast: false matrix: command: diff --git a/metadata-ingestion/src/datahub/ingestion/graph/client.py b/metadata-ingestion/src/datahub/ingestion/graph/client.py index 6c66ec9f3f..f0dbfed453 100644 --- a/metadata-ingestion/src/datahub/ingestion/graph/client.py +++ b/metadata-ingestion/src/datahub/ingestion/graph/client.py @@ -12,6 +12,7 @@ from requests.models import HTTPError from datahub.cli.cli_utils import get_boolean_env_variable, get_url_and_token from datahub.configuration.common import ConfigModel, GraphError, OperationalError +from datahub.emitter.aspect import TIMESERIES_ASPECT_MAP from datahub.emitter.mce_builder import Aspect from datahub.emitter.rest_emitter import DatahubRestEmitter from datahub.emitter.serialization_helper import post_json_transform @@ -131,10 +132,16 @@ class DataHubGraph(DatahubRestEmitter): :param version: The version of the aspect to retrieve. The default of 0 means latest. Versions > 0 go from oldest to newest, so 1 is the oldest. :return: the Aspect as a dictionary if present, None if no aspect was found (HTTP status 404) + :raises TypeError: if the aspect type is a timeseries aspect :raises HttpError: if the HTTP response is not a 200 or a 404 """ aspect = aspect_type.ASPECT_NAME + if aspect in TIMESERIES_ASPECT_MAP: + raise TypeError( + 'Cannot get a timeseries aspect using "get_aspect". Use "get_latest_timeseries_value" instead.' + ) + url: str = f"{self._gms_server}/aspects/{Urn.url_encode(entity_urn)}?aspect={aspect}&version={version}" response = self._session.get(url) if response.status_code == 404: