From 47159f338dca23002c575d91bc615d8efcdce686 Mon Sep 17 00:00:00 2001 From: TLSM Date: Fri, 24 Jun 2022 15:26:18 -0400 Subject: [PATCH] Fix exception when serializing comments JSON. The JSON API endpoints that return comments, most notably `/comments` returned 500s and created a stack trace with: TypeError: Object of type method is not JSON serializable Further debugging revealed this was because json.encoder was being given a .wrapper of > to serialize. The introduction of the bug was traced to 8ecb4582d066 where it was discovered that the (seemingly inadvertent) removal of the @property decorator on classes/comment.py:parent_fullname was the root cause. In light of the fact that parent_fullname was unrelated to the changes intended in 8ecb4582d066 and that no other refactoring around parent_fullname was done, it was restored to being a @property rather than its callers modified to invoke it as a method. --- files/classes/comment.py | 1 + 1 file changed, 1 insertion(+) diff --git a/files/classes/comment.py b/files/classes/comment.py index 340c00917..480eb4171 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -235,6 +235,7 @@ class Comment(Base): else: return g.db.get(Comment, self.parent_comment_id) + @property @lazy def parent_fullname(self): if self.parent_comment_id: return f"t3_{self.parent_comment_id}"