Fix TestCampaign sending only subscribers, failing listmonk validation
CI / test (push) Successful in 9s

listmonk's /api/campaigns/:id/test handler binds the request into the
same campReq struct create/update use and validates it in full, so a
request with only {"subscribers": [...]} fails with "Invalid length
for name" before subscribers is ever read. TestCampaign now sends the
campaign's full CampaignInput alongside subscribers.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-23 21:51:20 -04:00
parent 7eea2b1a8b
commit 39d02303c7
4 changed files with 33 additions and 8 deletions
+1 -1
View File
@@ -39,5 +39,5 @@ func Test(lm *listmonk.Client, slug string, emails []string) error {
if camp == nil {
return fmt.Errorf("no campaign named %q in listmonk — run sync first", slug)
}
return lm.TestCampaign(camp.ID, emails)
return lm.TestCampaign(camp.ID, camp.AsInput(), emails)
}
+1 -1
View File
@@ -137,7 +137,7 @@ func syncOne(lm *listmonk.Client, slug, dir, path string, defaultPreviewEmails [
}
var previewErr error
if len(recipients) > 0 {
previewErr = lm.TestCampaign(campaignID, recipients)
previewErr = lm.TestCampaign(campaignID, input, recipients)
}
return syncOneResult{Changed: true, PreviewErr: previewErr}, nil
}