{"record":{"id":"b66876c48592486b","repo":"Billionmail/BillionMail","slug":"sender-email-is-required","errorCode":null,"errorMessage":"sender email is required","messagePattern":"sender email is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/controller/settings/settings_v1_set_blacklist_alert_settings.go","lineNumber":68,"sourceCode":"\tjsonData, err := json.MarshalIndent(data, \"\", \"  \")\n\tif err != nil {\n\t\tres.SetError(gerror.Newf(public.LangCtx(ctx, \"Failed to encode alert settings: {}\", err.Error())))\n\t\treturn res, nil\n\t}\n\n\terr = gfile.PutContents(alertSettingsFile, string(jsonData))\n\tif err != nil {\n\t\tres.SetError(gerror.Newf(public.LangCtx(ctx, \"Failed to save alert settings: {}\", err.Error())))\n\t\treturn res, nil\n\t}\n\n\tres.SetSuccess(public.LangCtx(ctx, \"Alert settings saved successfully and test email sent\"))\n\treturn res, nil\n}\n\nfunc validateAlertSettings(settings *v1.SetBlacklistAlertSettingsReq) error {\n\tif settings.SenderEmail == \"\" {\n\t\treturn fmt.Errorf(\"sender email is required\")\n\t}\n\n\tif !strings.Contains(settings.SenderEmail, \"@\") {\n\t\treturn fmt.Errorf(\"invalid sender email format\")\n\t}\n\n\tif settings.SMTPServer == \"\" {\n\t\treturn fmt.Errorf(\"SMTP server is required\")\n\t}\n\n\tif settings.SMTPPort < 1 || settings.SMTPPort > 65535 {\n\t\treturn fmt.Errorf(\"SMTP port must be between 1 and 65535\")\n\t}\n\n\tif settings.SMTPPassword == \"\" {\n\t\treturn fmt.Errorf(\"SMTP password is required\")\n\t}\n","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/controller/settings/settings_v1_set_blacklist_alert_settings.go#L50-L86","documentation":"validateAlertSettings (used by SetBlacklistAlertSettings) requires a non-empty SenderEmail because alert notifications must have a From address. An empty string fails the first check and the settings are not saved.","triggerScenarios":"Calling SetBlacklistAlertSettings with senderEmail omitted, set to \"\", or whitespace-only in the request body.","commonSituations":"Frontend forms submitted without filling the sender field, API scripts that skip optional-looking fields, or clients that send null which deserializes to the empty string.","solutions":["Provide a valid sender email, e.g. alerts@example.com","Enable the sender field as required in the UI and validate before submit","Trim the input and reject whitespace-only values client-side","Use an address on a domain the mail server can send from (SPF/DKIM configured)"],"exampleFix":"// before\n{ \"senderEmail\": \"\" }\n// after\n{ \"senderEmail\": \"alerts@example.com\" }","handlingStrategy":"validation","validationCode":"const sender = (settings.senderEmail ?? '').trim();\nif (!sender) throw new Error('sender email is required');","typeGuard":"function hasSenderEmail(s: unknown): s is { senderEmail: string } {\n  return typeof s === 'object' && s !== null && typeof (s as any).senderEmail === 'string' && (s as any).senderEmail.trim() !== '';\n}","tryCatchPattern":"try {\n  await api.setBlacklistAlertSettings(settings);\n} catch (e) {\n  if (String(e.message).includes('sender email is required')) {\n    notify('Sender email is a required field');\n    focusSenderField();\n  } else throw e;\n}","preventionTips":["Mark sender email required in the form UI","Trim and reject whitespace-only input before submit","Coerce null/undefined to '' and check before calling the API","Default to a sensible address like alerts@<your-domain> when appropriate"],"tags":["validation","email","blacklist-alerts"],"backgroundTag":"missing-required-argument","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}