~sircmpwn/sr.ht-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 3

[PATCH lists.sr.ht 1/2] api/graph: skip emails with decoding errors in threadResolver.Blocks

Details
Message ID
<20230314161502.414711-1-contact@emersion.fr>
DKIM signature
pass
Download raw message
Patch: +5 -2
Some emails can have a bad encoding, a bad charset, a bad header
field, etc. Skip these so that we can try to return a partial thread.

Ideally we'd return a list of errors alongside the partial thread,
but gqlgen doesn't support this yet.
---
 api/graph/schema.resolvers.go | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/api/graph/schema.resolvers.go b/api/graph/schema.resolvers.go
index 7d6692d16121..89f799c986bf 100644
--- a/api/graph/schema.resolvers.go
+++ b/api/graph/schema.resolvers.go
@@ -10,6 +10,7 @@ import (
	"errors"
	"fmt"
	"io"
	"log"
	"net/url"
	"strings"
	"time"
@@ -1827,12 +1828,14 @@ func (r *threadResolver) Blocks(ctx context.Context, obj *model.Thread) ([]*mode

			mr, err := mail.CreateReader(bytes.NewReader(email.RawEnvelope))
			if err != nil {
				return fmt.Errorf("failed to create mail reader: %v", err)
				log.Printf("Failed to create reader for email %v: %v", email.ID, err)
				continue
			}
			header := mr.Header
			text, err := getMailText(mr)
			if err != nil {
				return fmt.Errorf("failed to get mail text: %v", err)
				log.Printf("Failed to get mail text for email %v: %v", email.ID, err)
				continue
			}
			mr.Close()


base-commit: fdc1c4c7c546ed32e42c8f014873e94c2e7d91f1
-- 
2.39.2

[PATCH lists.sr.ht 2/2] Make thread block parsing errors non-fatal

Details
Message ID
<20230314161502.414711-2-contact@emersion.fr>
In-Reply-To
<20230314161502.414711-1-contact@emersion.fr> (view parent)
DKIM signature
pass
Download raw message
Patch: +27 -20
---
 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, ToolIcon
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] = msg

    feedback = dict()
    resp = 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 = exec_gql(current_app.site, """
            query GetPatchsetThreadBlocks($patchset: Int!) {
                patchset(id: $patchset) {
                    thread {
                        blocks {
                            key
                            source {
                                id
                            }
                            sourceRange {
                                start
                                end
                            }
                            parentRange {
                                start
                                end
                            }
                        }
                    }
                }
            }
        }
    """, user=owner, patchset=patchset_id)
    blocks = resp["patchset"]["thread"]["blocks"]
        """, user=owner, patchset=patchset_id)
        blocks = 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 = []
    for block in blocks:
        source_email = messages_by_id[block["source"]["id"]]

-- 
2.39.2

[lists.sr.ht/patches] build failed

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CR68QW2ZWC2N.23S7L1ZTPG225@cirno2>
In-Reply-To
<20230314161502.414711-2-contact@emersion.fr> (view parent)
DKIM signature
missing
Download raw message
lists.sr.ht/patches: FAILED in 3m50s

[api/graph: skip emails with decoding errors in threadResolver.Blocks][0] from [Simon Ser][1]

[0]: https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/39710
[1]: contact@emersion.fr

✓ #957088 SUCCESS lists.sr.ht/patches/debian.yml    https://builds.sr.ht/~sircmpwn/job/957088
✗ #957087 FAILED  lists.sr.ht/patches/archlinux.yml https://builds.sr.ht/~sircmpwn/job/957087
✓ #957086 SUCCESS lists.sr.ht/patches/alpine.yml    https://builds.sr.ht/~sircmpwn/job/957086

Re: [PATCH lists.sr.ht 2/2] Make thread block parsing errors non-fatal

Details
Message ID
<CR6WZGH0BF1T.39RTC6YWNFM9V@taiga>
In-Reply-To
<20230314161502.414711-2-contact@emersion.fr> (view parent)
DKIM signature
pass
Download raw message
Thanks!

To git@git.sr.ht:~sircmpwn/lists.sr.ht
   fdc1c4c..8aa7a45  master -> master
Reply to thread Export thread (mbox)