From 15c90b2b7245bcf19b11aa17ac0be3c7d70bac4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Fri, 10 Apr 2026 15:41:21 +0400 Subject: [PATCH] Fix validation and data access layer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Émile Ré --- pkg/cookiebanner/client.go | 1 + pkg/coredata/cookie_banner.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/cookiebanner/client.go b/pkg/cookiebanner/client.go index 6ea0541a8..33ddfd619 100644 --- a/pkg/cookiebanner/client.go +++ b/pkg/cookiebanner/client.go @@ -127,6 +127,7 @@ func (r *UpdateCookieCategoryRequest) Validate() error { v.Check(r.CookieCategoryID, "cookie_category_id", validator.Required(), validator.GID(coredata.CookieCategoryEntityType)) v.Check(r.Name, "name", validator.SafeTextNoNewLine(255)) v.Check(r.Description, "description", validator.SafeText(1000)) + v.Check(r.Rank, "rank", validator.Min(0)) return v.Error() } diff --git a/pkg/coredata/cookie_banner.go b/pkg/coredata/cookie_banner.go index 7652e8a22..614c5c398 100644 --- a/pkg/coredata/cookie_banner.go +++ b/pkg/coredata/cookie_banner.go @@ -338,11 +338,15 @@ WHERE } maps.Copy(args, scope.SQLArguments()) - _, err := tx.Exec(ctx, q, args) + result, err := tx.Exec(ctx, q, args) if err != nil { return fmt.Errorf("cannot update cookie banner: %w", err) } + if result.RowsAffected() == 0 { + return ErrResourceNotFound + } + return nil }