# HG changeset patch # User Mads Kiilerich # Date 2015-08-17 01:11:42 # Node ID 74d5ae62bf74f242c4bf02beab363744d7c838ab # Parent 0b9aadc314de5d41969d7dc6d5da25d55a3eefce db: better handling of decoding of changeset_cache values from the database Do some validation of the data to prevent that incorrect data cause weird failures when they are used later on. diff --git a/kallithea/model/db.py b/kallithea/model/db.py --- a/kallithea/model/db.py +++ b/kallithea/model/db.py @@ -1051,14 +1051,12 @@ class Repository(Base, BaseModel): @hybrid_property def changeset_cache(self): - from kallithea.lib.vcs.backends.base import EmptyChangeset - dummy = EmptyChangeset().__json__() - if not self._changeset_cache: - return dummy try: - return json.loads(self._changeset_cache) - except TypeError: - return dummy + cs_cache = json.loads(self._changeset_cache) # might raise on bad data + cs_cache['raw_id'] # verify data, raise exception on error + return cs_cache + except (TypeError, KeyError, ValueError): + return EmptyChangeset().__json__() @changeset_cache.setter def changeset_cache(self, val):