You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2018/08/09 17:56:37 UTC

[GitHub] Noremac201 commented on a change in pull request #3648: [AIRFLOW-2786] Fix editing Variable with empty key crashing

Noremac201 commented on a change in pull request #3648: [AIRFLOW-2786] Fix editing Variable with empty key crashing
URL: https://github.com/apache/incubator-airflow/pull/3648#discussion_r209023497
 
 

 ##########
 File path: airflow/www/views.py
 ##########
 @@ -2012,9 +2012,20 @@ def varimport(self):
         except Exception as e:
             flash("Missing file or syntax error: {}.".format(e))
         else:
+            suc_count = fail_count = 0
             for k, v in d.items():
-                models.Variable.set(k, v, serialize_json=isinstance(v, dict))
-            flash("{} variable(s) successfully updated.".format(len(d)))
+                try:
+                    models.Variable.set(k, v, serialize_json=isinstance(v, dict))
+                except Exception as e:
+                    logging.warning(e)
+                    fail_count += 1
+                else:
+                    suc_count += 1
+            flash("{} variable(s) successfully updated.".format(suc_count), 'info')
 
 Review comment:
   As far as I can tell, if an exception is thrown because of Unicode decoding error, it will throw another  exception when trying to log or `flash` the Variable key to the user, which is why I don't think it's possible to show which ones failed to import.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services