From 89c17d8294b57ec68cca579d53ff75250f2e819a Mon Sep 17 00:00:00 2001 From: TalLevAmi Date: Sun, 27 Sep 2026 06:56:11 +0000 Subject: [PATCH] Do not send an empty `format` in `PrivateDownloadURL` `PrivateDownloadURLParams.Format` had the tag `json:"format"` with no `omitempty`, so a URL with no format included and signed `format=`. The server drops empty values before it checks the signature, so these URLs failed with "Invalid Signature". Add `omitempty` to the tag. Co-Authored-By: Claude Opus 5.5 --- api/uploader/archive.go | 2 +- api/uploader/archive_test.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/api/uploader/archive.go b/api/uploader/archive.go index 47f5672..11f901c 100644 --- a/api/uploader/archive.go +++ b/api/uploader/archive.go @@ -172,7 +172,7 @@ func (u *API) DownloadBackedUpAsset(params DownloadBackedUpAssetParams) (string, // PrivateDownloadURLParams are the parameters for PrivateDownloadURL. type PrivateDownloadURLParams struct { PublicID string `json:"public_id"` - Format string `json:"format"` + Format string `json:"format,omitempty"` DeliveryType string `json:"type,omitempty"` Attachment string `json:"attachment,omitempty"` ExpiresAt *time.Time `json:"expires_at,omitempty"` diff --git a/api/uploader/archive_test.go b/api/uploader/archive_test.go index 5692c08..9a028df 100644 --- a/api/uploader/archive_test.go +++ b/api/uploader/archive_test.go @@ -100,3 +100,15 @@ func TestUploader_PrivateDownloadURL(t *testing.T) { assert.Contains(t, privateDownloadURL, "signature") assert.Contains(t, privateDownloadURL, "timestamp") } + +func TestUploader_PrivateDownloadURLWithoutFormat(t *testing.T) { + params := uploader.PrivateDownloadURLParams{ + PublicID: cldtest.PublicID, + } + + privateDownloadURL, err := uploadAPI.PrivateDownloadURL(params) + + assert.NoError(t, err) + assert.Contains(t, privateDownloadURL, "public_id="+cldtest.PublicID) + assert.NotContains(t, privateDownloadURL, "format=") +}