From 9cc14ac5c7029a3a64bbd5fee59a598cc5fcabb8 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sun, 18 Apr 2021 11:33:14 +0200 Subject: [PATCH] Fix for #1905 prevent invalid json data in gmail_token --- cps/config_sql.py | 6 ++++-- cps/services/gmail.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cps/config_sql.py b/cps/config_sql.py index 6e13489d..f7419ec9 100644 --- a/cps/config_sql.py +++ b/cps/config_sql.py @@ -20,6 +20,7 @@ from __future__ import division, print_function, unicode_literals import os import sys +import json from sqlalchemy import Column, String, Integer, SmallInteger, Boolean, BLOB, JSON from sqlalchemy.exc import OperationalError @@ -261,7 +262,6 @@ class _ConfigSQL(object): """ new_value = dictionary.get(field, default) if new_value is None: - # log.debug("_ConfigSQL set_from_dictionary field '%s' not found", field) return False if field not in self.__dict__: @@ -278,7 +278,6 @@ class _ConfigSQL(object): if current_value == new_value: return False - # log.debug("_ConfigSQL set_from_dictionary '%s' = %r (was %r)", field, new_value, current_value) setattr(self, field, new_value) return True @@ -383,6 +382,9 @@ def _migrate_table(session, orm_class): log.debug(alter_table) session.execute(alter_table) changed = True + except json.decoder.JSONDecodeError as e: + log.error("Database corrupt column: {}".format(column_name)) + log.debug(e) if changed: try: diff --git a/cps/services/gmail.py b/cps/services/gmail.py index 9524dd75..f85d56b0 100644 --- a/cps/services/gmail.py +++ b/cps/services/gmail.py @@ -53,6 +53,7 @@ def setup_gmail(token): 'expiry': creds.expiry.isoformat(), 'email': user_info } + return {} def get_user_info(credentials): user_info_service = build(serviceName='oauth2', version='v2',credentials=credentials)