From c6fd29978813b5ec98b621a211df5b2ec88055c3 Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Sun, 7 Jul 2013 12:09:30 -0700 Subject: [PATCH] POST_expando: gracefully fail when called on link with no child. Previously if POST_expando was called on a link that has no link_child (i.e. no selftext or media object to show in the expando) it would cause an exception. This catches the bad case early and aborts with a 404. --- r2/r2/controllers/api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index 9cefebe18..57fbc16b3 100755 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -3162,7 +3162,10 @@ class ApiController(RedditController, OAuth2ResourceController): wrapped = wrap_links(link) wrapped = list(wrapped)[0] - return websafe(spaceCompress(wrapped.link_child.content())) + link_child = wrapped.link_child + if not link_child: + abort(404, 'not found') + return websafe(spaceCompress(link_child.content())) @validatedForm(VUser('password', default=''), VModhash(),