From 14f59a3d2811f6e29c585a4f87a1d0819d51e069 Mon Sep 17 00:00:00 2001 From: Adam French Date: Mon, 19 Oct 2026 19:55:50 +0100 Subject: [PATCH] =?UTF-8?q?fix(qa):=20ISSUE-003=20=E2=80=94=20reject=20pos?= =?UTF-8?q?ts=20without=20a=20title?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit createPost stored whatever it was given, so pressing Upload on the empty admin Post form published a blank post to the feed. Refuse a blank title, as createPage already does. Co-Authored-By: Claude Opus 5.5 --- backend/graph/post.resolvers.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/graph/post.resolvers.go b/backend/graph/post.resolvers.go index 8dc1e53..7ea119c 100644 --- a/backend/graph/post.resolvers.go +++ b/backend/graph/post.resolvers.go @@ -8,6 +8,7 @@ package graph import ( "context" "fmt" + "strings" "adam-french.co.uk/backend/graph/model" "adam-french.co.uk/backend/models" @@ -23,6 +24,12 @@ func (r *mutationResolver) CreatePost(ctx context.Context, input model.CreatePos return nil, fmt.Errorf("unauthorized") } + // The admin form submits whatever is in its fields, so an accidental click + // on an empty form would otherwise publish a blank post to the feed. + if strings.TrimSpace(input.Title) == "" { + return nil, fmt.Errorf("a post needs a title") + } + post := models.Post{Title: input.Title, Content: input.Content, AuthorID: userID} if err := r.Store.DB.Create(&post).Error; err != nil { return nil, err