mirror of
https://github.com/datahub-project/datahub.git
synced 2025-09-25 17:15:09 +00:00
fix(cli): protect against timeseries get_aspects (#7665)
This commit is contained in:
parent
f872ca9cba
commit
3b519924e8
1
.github/workflows/check-datahub-jars.yml
vendored
1
.github/workflows/check-datahub-jars.yml
vendored
@ -25,6 +25,7 @@ concurrency:
|
|||||||
jobs:
|
jobs:
|
||||||
check_jars:
|
check_jars:
|
||||||
strategy:
|
strategy:
|
||||||
|
max-parallel: 1
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
command:
|
command:
|
||||||
|
@ -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.cli.cli_utils import get_boolean_env_variable, get_url_and_token
|
||||||
from datahub.configuration.common import ConfigModel, GraphError, OperationalError
|
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.mce_builder import Aspect
|
||||||
from datahub.emitter.rest_emitter import DatahubRestEmitter
|
from datahub.emitter.rest_emitter import DatahubRestEmitter
|
||||||
from datahub.emitter.serialization_helper import post_json_transform
|
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.
|
: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)
|
: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
|
:raises HttpError: if the HTTP response is not a 200 or a 404
|
||||||
"""
|
"""
|
||||||
|
|
||||||
aspect = aspect_type.ASPECT_NAME
|
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}"
|
url: str = f"{self._gms_server}/aspects/{Urn.url_encode(entity_urn)}?aspect={aspect}&version={version}"
|
||||||
response = self._session.get(url)
|
response = self._session.get(url)
|
||||||
if response.status_code == 404:
|
if response.status_code == 404:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user