From 736e9107fbf83bb6324f970f30f844a60339ca96 Mon Sep 17 00:00:00 2001 From: miliv Date: Tue, 22 Nov 2022 16:18:14 +0100 Subject: [PATCH 1/3] Print error message while calling GMS from python --- metadata-ingestion/src/datahub/cli/cli_utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/metadata-ingestion/src/datahub/cli/cli_utils.py b/metadata-ingestion/src/datahub/cli/cli_utils.py index 5bd8841e6755a..7100ef67b5fd4 100644 --- a/metadata-ingestion/src/datahub/cli/cli_utils.py +++ b/metadata-ingestion/src/datahub/cli/cli_utils.py @@ -581,6 +581,9 @@ def post_entity( curl_command, ) response = session.post(url, payload) + jsonResponse = json.loads(response.content) + if 'message' in jsonResponse: + log.error(jsonResponse['message'].strip()) response.raise_for_status() return response.status_code From d0a8f15ad432613321db488af1a5abaff50a151d Mon Sep 17 00:00:00 2001 From: miliv Date: Thu, 24 Nov 2022 09:04:59 +0100 Subject: [PATCH 2/3] Use response.json() --- metadata-ingestion/src/datahub/cli/cli_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/metadata-ingestion/src/datahub/cli/cli_utils.py b/metadata-ingestion/src/datahub/cli/cli_utils.py index 7100ef67b5fd4..b8459df27dbbb 100644 --- a/metadata-ingestion/src/datahub/cli/cli_utils.py +++ b/metadata-ingestion/src/datahub/cli/cli_utils.py @@ -581,9 +581,9 @@ def post_entity( curl_command, ) response = session.post(url, payload) - jsonResponse = json.loads(response.content) - if 'message' in jsonResponse: - log.error(jsonResponse['message'].strip()) + response_json = response.json() + if 'message' in response_json: + log.error(response_json['message'].strip()) response.raise_for_status() return response.status_code From 0afc977f3dbd7a5a7aeb496087d8db7a3e363a9e Mon Sep 17 00:00:00 2001 From: Harshal Sheth Date: Fri, 2 Dec 2022 00:54:35 -0500 Subject: [PATCH 3/3] fix error handling --- metadata-ingestion/src/datahub/cli/cli_utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/metadata-ingestion/src/datahub/cli/cli_utils.py b/metadata-ingestion/src/datahub/cli/cli_utils.py index b8459df27dbbb..d6ece814c9c47 100644 --- a/metadata-ingestion/src/datahub/cli/cli_utils.py +++ b/metadata-ingestion/src/datahub/cli/cli_utils.py @@ -581,9 +581,11 @@ def post_entity( curl_command, ) response = session.post(url, payload) - response_json = response.json() - if 'message' in response_json: - log.error(response_json['message'].strip()) + if not response.ok: + try: + log.info(response.json()["message"].strip()) + except Exception: + log.info(f"post_entity failed: {response.text}") response.raise_for_status() return response.status_code