potiuk commented on code in PR #24399:
URL: https://github.com/apache/airflow/pull/24399#discussion_r903456893


##########
airflow/www/views.py:
##########
@@ -3541,6 +3544,10 @@ def extra_links(self, session: "Session" = NEW_SESSION):
             response = jsonify({'url': None, 'error': 'Task Instances not 
found'})
             response.status_code = 404
             return response
+        if link_name is None:
+            response = jsonify({'url': None, 'error': 'Link name not passed'})
+            response.status_code = 400
+            return response

Review Comment:
   I prefer to explicitly handle the error. The `requests.args["link_name"] 
will fail with ugly 500 error with - usually - cryptic stackrace, but this is 
really 400 -> bad request, and we should tell the user immediately what is 
wrong.
   
    But yeah. It can be moved a little higher (I just moved it and also moved 
link_name retrieval just before that check). We cannot move it up to the top (I 
think) , because lack of the valid "dag_id" /"task_id" combination is a bit 
more important (IMHO) than lack of link_name, and should be surfaced earlier.
   
   



##########
airflow/www/views.py:
##########
@@ -3541,6 +3544,10 @@ def extra_links(self, session: "Session" = NEW_SESSION):
             response = jsonify({'url': None, 'error': 'Task Instances not 
found'})
             response.status_code = 404
             return response
+        if link_name is None:
+            response = jsonify({'url': None, 'error': 'Link name not passed'})
+            response.status_code = 400
+            return response

Review Comment:
   I prefer to explicitly handle the error. The `requests.args["link_name"] 
will fail with ugly HTTP 500 with - usually - cryptic stackrace, but this is 
really 400 -> bad request, and we should tell the user immediately what is 
wrong.
   
    But yeah. It can be moved a little higher (I just moved it and also moved 
link_name retrieval just before that check). We cannot move it up to the top (I 
think) , because lack of the valid "dag_id" /"task_id" combination is a bit 
more important (IMHO) than lack of link_name, and should be surfaced earlier.
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to