diff --git a/app/main/controller/presto_controller.py b/app/main/controller/presto_controller.py index 83d5fa30..b5fb2c61 100644 --- a/app/main/controller/presto_controller.py +++ b/app/main/controller/presto_controller.py @@ -39,7 +39,7 @@ def post(self, action, model_type): if result: result["is_search_result_callback"] = True callback_url = data.get("body", {}).get("raw", {}).get("callback_url", app.config['CHECK_API_HOST']) or app.config['CHECK_API_HOST'] - if result and data.get("body", {}).get("raw", {}).get("requires_callback"): + if result and result.get("results") is not None and data.get("body", {}).get("raw", {}).get("requires_callback"): app.logger.info(f"Sending callback to {callback_url} for {action} for model of {model_type} with body of {result}") Webhook.return_webhook(callback_url, action, model_type, result) return_value = {"action": action, "model_type": model_type, "data": result} diff --git a/app/main/lib/elastic_crud.py b/app/main/lib/elastic_crud.py index b28e3b3c..e8732d3b 100644 --- a/app/main/lib/elastic_crud.py +++ b/app/main/lib/elastic_crud.py @@ -54,7 +54,7 @@ def get_blocked_presto_response(task, model, modality): callback_url = Presto.add_item_callback_url(app.config['ALEGRE_HOST'], modality) if requires_encoding(obj): blocked_results = [] - for model_key in obj.pop("models", []): + for model_key in obj.get("models", []): if model_key != "elasticsearch" and not obj.get('model_'+model_key): response = get_presto_request_response(model_key, callback_url, obj) blocked_results.append({"model": model_key, "response": Presto.blocked_response(response, modality)})