From e73dc9dc9b8607b166f23d21da2e1dd4609df132 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Mon, 11 May 2026 21:40:57 +0000 Subject: [PATCH] Fix hydration to not return when there's no error This is a subtlety that comes from incorrectly assigning n ErrorWithStatus to an error variable/pointer. --- resource/communication.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/resource/communication.go b/resource/communication.go index 87806566..6d18e093 100644 --- a/resource/communication.go +++ b/resource/communication.go @@ -83,9 +83,9 @@ func (res *communicationR) List(ctx context.Context, r *http.Request, user platf if !ok { return nil, nhttp.NewError("lookup report id %d failed", comm.SourceReportID) } - c, err := res.hydrateCommunicationStub(comm, &public_report) - if err != nil { - return nil, err + c, e := res.hydrateCommunicationStub(comm, &public_report) + if e != nil { + return nil, e } result[i] = c } @@ -107,10 +107,9 @@ func (res *communicationR) MarkPossibleResolved(ctx context.Context, r *http.Req return res.markCommunication(ctx, r, user, "possible-resolved", platform.CommunicationMarkPossibleResolved) } func (res *communicationR) hydrateCommunication(comm modelpublic.Communication, public_report *modelpublicreport.Report) (communication, *nhttp.ErrorWithStatus) { - var err error - stub, err := res.hydrateCommunicationStub(comm, public_report) - if err != nil { - return communication{}, nhttp.NewError("hydrate stub: %w", err) + stub, e := res.hydrateCommunicationStub(comm, public_report) + if e != nil { + return communication{}, e } response, err := responseURI(*res.router, comm) if err != nil { @@ -149,12 +148,6 @@ func (res *communicationR) hydrateCommunicationStub(comm modelpublic.Communicati } source_uri = "text" } - /* - response, err := responseURI(*res.router, comm) - if err != nil { - return communicationStub{}, nhttp.NewError("gen response URI: %w", err) - } - */ uri, err := res.router.IDToURI("communication.ByIDGet", int(comm.ID)) if err != nil { return communicationStub{}, nhttp.NewError("gen comm uri: %w", err)