Unverified Commit a8cedea1 authored by Garfield Dai's avatar Garfield Dai Committed by GitHub

fix: check result should be string. (#1959)

parent 87832ede
......@@ -58,7 +58,7 @@ class ApiExternalDataTool(ExternalDataTool):
if not api_based_extension:
raise ValueError("[External data tool] API query failed, variable: {}, "
"error: api_based_extension_id is invalid"
.format(self.config.get('variable')))
.format(self.variable))
# decrypt api_key
api_key = encrypter.decrypt_token(
......@@ -74,7 +74,7 @@ class ApiExternalDataTool(ExternalDataTool):
)
except Exception as e:
raise ValueError("[External data tool] API query failed, variable: {}, error: {}".format(
self.config.get('variable'),
self.variable,
e
))
......@@ -87,6 +87,10 @@ class ApiExternalDataTool(ExternalDataTool):
if 'result' not in response_json:
raise ValueError("[External data tool] API query failed, variable: {}, error: result not found in response"
.format(self.config.get('variable')))
.format(self.variable))
if not isinstance(response_json['result'], str):
raise ValueError("[External data tool] API query failed, variable: {}, error: result is not string"
.format(self.variable))
return response_json['result']
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment