~netlandish/links-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
1

[PATCH links] Fixes a bug when a user submits all invalid tags we don't try to do an empty insert. Caused by spammers but a bug none the less.

Details
Message ID
<20250829205026.8824-1-peter@netlandish.com>
Sender timestamp
1756479024
DKIM signature
missing
Download raw message
Patch: +12 -0
Changelog-fixed: Edge case where all submitted tags are invalid
  resulting in an sql error (empty insert).
---
 models/org_link.go        | 3 +++
 models/tag_link_shorts.go | 3 +++
 models/tag_links.go       | 3 +++
 models/tag_listing.go     | 3 +++
 4 files changed, 12 insertions(+)

diff --git a/models/org_link.go b/models/org_link.go
index 330894c..9e4829e 100644
--- a/models/org_link.go
+++ b/models/org_link.go
@@ -272,6 +272,9 @@ func GetOrgLinksAnalytics(ctx context.Context, opts *database.FilterOptions) ([]
}

func OrgLinkStoreBatch(ctx context.Context, links []*OrgLink) error {
	if len(links) == 0 {
		return nil
	}
	err := database.WithTx(ctx, nil, func(tx *sql.Tx) error {
		batch := sq.
			Insert("org_links").
diff --git a/models/tag_link_shorts.go b/models/tag_link_shorts.go
index 4e0bc6b..6530864 100644
--- a/models/tag_link_shorts.go
+++ b/models/tag_link_shorts.go
@@ -61,6 +61,9 @@ func GetTagLinkShort(ctx context.Context, id int) (*TagLinkShort, error) {
}

func CreateBatchTagLinkShorts(ctx context.Context, linkShortID int, tagIDs []int) error {
	if len(tagIDs) == 0 {
		return nil
	}
	err := database.WithTx(ctx, nil, func(tx *sql.Tx) error {
		var err error
		q := sq.
diff --git a/models/tag_links.go b/models/tag_links.go
index beaf159..9c6a634 100644
--- a/models/tag_links.go
+++ b/models/tag_links.go
@@ -61,6 +61,9 @@ func GetTagLink(ctx context.Context, id int) (*TagLink, error) {
}

func CreateBatchTagLinks(ctx context.Context, linkID int, tagIDs []int) error {
	if len(tagIDs) == 0 {
		return nil
	}
	err := database.WithTx(ctx, nil, func(tx *sql.Tx) error {
		var err error
		q := sq.
diff --git a/models/tag_listing.go b/models/tag_listing.go
index a11a110..a0f05b3 100644
--- a/models/tag_listing.go
+++ b/models/tag_listing.go
@@ -61,6 +61,9 @@ func GetTagListing(ctx context.Context, id int) (*TagListing, error) {
}

func CreateBatchTagListings(ctx context.Context, linkShortID int, tagIDs []int) error {
	if len(tagIDs) == 0 {
		return nil
	}
	err := database.WithTx(ctx, nil, func(tx *sql.Tx) error {
		var err error
		q := sq.
-- 
2.49.1
Details
Message ID
<DCF7NDQFGBLE.2JPFLLOJMN9P0@netlandish.com>
In-Reply-To
<20250829205026.8824-1-peter@netlandish.com> (view parent)
Sender timestamp
1756479430
DKIM signature
missing
Download raw message
Applied.

To git@git.code.netlandish.com:~netlandish/links
   001c767..89e69a6  master -> master
Reply to thread Export thread (mbox)