knadh/listmonk · error
campaigns.fieldInvalidName
Error message
campaigns.fieldInvalidName
What it means
validateCampaignFields enforces strHasLen(c.Name, 1, stdInputMaxLen): the campaign name must be between 1 and stdInputMaxLen characters. The error is returned for empty names or names exceeding the standard input limit.
Source
Thrown at cmd/campaigns.go:690
a.log.Printf("error rendering message: %v", err)
return echo.NewHTTPError(http.StatusNotFound, a.i18n.Ts("templates.errorRendering", "error", err.Error()))
}
return a.manager.PushCampaignMessage(msg)
}
// validateCampaignFields validates incoming campaign field values.
func (a *App) validateCampaignFields(c campReq) (campReq, error) {
if c.FromEmail == "" {
c.FromEmail = a.cfg.FromEmail
} else if !reFromAddress.Match([]byte(c.FromEmail)) {
if _, err := a.importer.SanitizeEmail(c.FromEmail); err != nil {
return c, errors.New(a.i18n.T("campaigns.fieldInvalidFromEmail"))
}
}
if !strHasLen(c.Name, 1, stdInputMaxLen) {
return c, errors.New(a.i18n.T("campaigns.fieldInvalidName"))
}
// Larger char limit for subject as it can contain {{ go templating }} logic.
if !strHasLen(c.Subject, 1, 5000) {
return c, errors.New(a.i18n.T("campaigns.fieldInvalidSubject"))
}
// If no content-type is specified, default to richtext.
if c.ContentType != models.CampaignContentTypeRichtext &&
c.ContentType != models.CampaignContentTypeHTML &&
c.ContentType != models.CampaignContentTypePlain &&
c.ContentType != models.CampaignContentTypeVisual &&
c.ContentType != models.CampaignContentTypeMarkdown {
c.ContentType = models.CampaignContentTypeRichtext
}
if c.ContentType != models.CampaignContentTypeVisual {
c.BodySource.Valid = falseView on GitHub (pinned to 670c01717d)
Solutions
- Provide a non-empty name within stdInputMaxLen characters in the request body.
- Trim the name and shorten it programmatically before calling the API.
- In UI clients, enforce a maxlength input attribute and require the field before submit.
Example fix
// before
{"name": ""}
// after
{"name": "August Newsletter 2026"} Defensive patterns
Strategy: validation
Validate before calling
function validateCampaignName(name) {
if (typeof name !== 'string' || name.trim().length === 0 || name.length > 200 /* stdInputMaxLen */) {
throw new Error('campaign name must be 1-200 characters');
}
} Type guard
function hasValidName(v: unknown): v is string {
return typeof v === 'string' && v.length >= 1 && v.length <= 200;
} Try / catch
try {
await api.createCampaign({ name, ...rest });
} catch (e) {
if (e.message.includes('fieldInvalidName')) {
throw new Error('Campaign name is required (max ~200 chars)');
}
throw e;
} Prevention
- Make name a required, non-blank field in any UI or automation that creates campaigns.
- Truncate auto-generated names to the length cap.
- Reject whitespace-only names client-side.
When it happens
Trigger: CreateCampaign, UpdateCampaign, or TestCampaign called with a JSON body where 'name' is absent, empty string, whitespace-only (not trimmed by validator), or longer than stdInputMaxLen characters.
Common situations: Automated API scripts that forget the name field, bulk import payloads with null/empty names, or names built from templated strings that exceed the length cap.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- campaigns.fieldInvalidFromEmail
- campaigns.fieldInvalidSubject
- campaigns.fieldInvalidSendAt
- campaigns.fieldInvalidListIDs
- campaigns.fieldInvalidBody
AI-assisted analysis of knadh/listmonk@670c01717d (2026-09-01).
Data as JSON: /api/errors/faf841a9829c8119.
Report an issue: GitHub.