From 22210a9ee65526ca0ccaf448260d2d9de0ff9c12 Mon Sep 17 00:00:00 2001 From: Zhenzan Zhou Date: Sun, 6 Sep 2015 17:09:44 +0800 Subject: [PATCH] Ignore KeyError for secret field Although it doesn't make sense to create a datasource without providing auth info in config info, it may be not possible to define a schema to verify because different datasource drivers may use different kinds of auth methods. So we should be able to handle the case that none secret info is provided. The fix just simply ignores KeyError exception here. Change-Id: I06bc6a4fb659d862da96dd96557454b6385d003f Closes-Bug: #1492354 --- congress/managers/datasource.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/congress/managers/datasource.py b/congress/managers/datasource.py index c11b3bfea..2dc008cd2 100644 --- a/congress/managers/datasource.py +++ b/congress/managers/datasource.py @@ -137,9 +137,13 @@ class DataSourceManager(object): for datasouce_driver in datasources_db.get_datasources(): result = cls.make_datasource_dict(datasouce_driver) if filter_secret: - hide_fields = cls.get_driver_info(result['driver'])['secret'] - for hide_field in hide_fields: - result['config'][hide_field] = "" + # secret field may be not provided while creating datasource + try: + hides = cls.get_driver_info(result['driver'])['secret'] + for hide_field in hides: + result['config'][hide_field] = "" + except KeyError: + pass results.append(result) return results