From 596e284fb7cb11cd0559644fafb4a7cfb51847f2 Mon Sep 17 00:00:00 2001 From: PIKACHUIM Date: Tue, 8 Sep 2026 19:29:42 +0800 Subject: [PATCH] fix(seed): allow capabilities preflight without seed_data SeedCapabilityReq embeds SeedDataReq whose SeedData field was bound with required. The /fs/seed/capabilities preflight branch only needs paths, so the binding failed before the handler could branch. Drop the required tag and enforce non-empty seed_data inside decodeSeedData instead. --- server/handles/torrent.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/handles/torrent.go b/server/handles/torrent.go index 360b898af..4f1d8e4da 100644 --- a/server/handles/torrent.go +++ b/server/handles/torrent.go @@ -450,8 +450,12 @@ func GenerateTorrentForPath(c *gin.Context) { } // SeedDataReq carries a bounded base64-encoded seed document. +// SeedData is intentionally NOT bound with `required` here: some requests that +// embed SeedDataReq (e.g. SeedCapabilityReq preflight) accept `paths` instead of +// `seed_data`. Required-ness is enforced inside decodeSeedData for the handlers +// that actually consume a seed document. type SeedDataReq struct { - SeedData string `json:"seed_data" binding:"required"` + SeedData string `json:"seed_data"` Format string `json:"format"` FileName string `json:"file_name"` } @@ -547,6 +551,9 @@ type SeedQuickSaveReq struct { } func decodeSeedData(req SeedDataReq) ([]byte, *torrent.Seed, string, error) { + if strings.TrimSpace(req.SeedData) == "" { + return nil, nil, "", fmt.Errorf("seed_data is required") + } if len(req.SeedData) > maxTorrentBase64Len { return nil, nil, "", fmt.Errorf("seed data is too large") }