Authentication-Results: mail-b.sr.ht; dkim=pass header.d=emersion.fr header.i=@emersion.fr Received: from mail-40136.proton.ch (mail-40136.proton.ch [185.70.40.136]) by mail-b.sr.ht (Postfix) with ESMTPS id B6B2411F30C for <~sircmpwn/sr.ht-dev@lists.sr.ht>; Tue, 14 Mar 2023 16:15:27 +0000 (UTC) Date: Tue, 14 Mar 2023 16:15:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emersion.fr; s=protonmail; t=1678810526; x=1679069726; bh=Z8gA7RBp9jBjJW5K2mY6ZeEOC37vEFvLcQuzYvwW5oE=; h=Date:To:From:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=KIyrSJWvtypak6LeX2RrWpBjGVt5myVox17jKjjuAS7O4MfDnCzNgKbPuFX1U9x7J 2XK83h1cg6cLOg0Rz1PKPnehOWGaje31hPcjeirAdUKRjdOWP2AW7RP7oKb1av9j+L kOfInKB2X2LkZOGJTXIG8QjOWV3iyGgFGuwZt71ds7eRDCsKQLNh2yopw8UC+YOo3H kbc8zNLzn6Nv6UOshjJjfeCXI1UJTnmjvsc+QIuUZ+bu9+SBF02E6SKaylF/jUdnaF 2ObcLDbXXRIjEEXhD7glq2yd7qYXNGlrzpl8CBpm5fvoEjCQ9qrSZUScjk3t0+mpn1 CpAWyGg58vrXQ== To: ~sircmpwn/sr.ht-dev@lists.sr.ht From: Simon Ser Subject: [PATCH lists.sr.ht 2/2] Make thread block parsing errors non-fatal Message-ID: <20230314161502.414711-2-contact@emersion.fr> In-Reply-To: <20230314161502.414711-1-contact@emersion.fr> References: <20230314161502.414711-1-contact@emersion.fr> Feedback-ID: 1358184:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --- listssrht/blueprints/patches.py | 47 +++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/listssrht/blueprints/patches.py b/listssrht/blueprints/patches= .py index cf6de0d428a5..bfb9aebe279d 100644 --- a/listssrht/blueprints/patches.py +++ b/listssrht/blueprints/patches.py @@ -13,7 +13,7 @@ from listssrht.types import Subscription, PatchsetTool, T= oolIcon from sqlalchemy import or_ from srht.database import db from srht.flask import paginate_query -from srht.graphql import exec_gql +from srht.graphql import exec_gql, GraphQLError from srht.markdown import markdown from srht.oauth import current_user, loginrequired from srht.validation import Validation @@ -155,29 +155,36 @@ def patchset(owner_name, list_name, patchset_id): messages_by_id[msg.id] =3D msg =20 feedback =3D dict() - resp =3D exec_gql(current_app.site, """ - query GetPatchsetThreadBlocks($patchset: Int!) { - patchset(id: $patchset) { - thread { - blocks { - key - source { - id - } - sourceRange { - start - end - } - parentRange { - start - end + try: + resp =3D exec_gql(current_app.site, """ + query GetPatchsetThreadBlocks($patchset: Int!) { + patchset(id: $patchset) { + thread { + blocks { + key + source { + id + } + sourceRange { + start + end + } + parentRange { + start + end + } } } } } - } - """, user=3Downer, patchset=3Dpatchset_id) - blocks =3D resp["patchset"]["thread"]["blocks"] + """, user=3Downer, patchset=3Dpatchset_id) + blocks =3D resp["patchset"]["thread"]["blocks"] + except GraphQLError as err: + # Can happen when an email in the thread is a bad apple + # TODO: grab partial result from GraphQLError.data (gqlgen doesn't + # support this yet) + print(f"Warning: failed to parse blocks from thread {thread.id}: {= err.errors}") + blocks =3D [] for block in blocks: source_email =3D messages_by_id[block["source"]["id"]] =20 --=20 2.39.2