{"record":{"id":"728e3fa434e27d9c","repo":"Billionmail/BillionMail","slug":"unable-to-determine-domain-for-noreply-email","errorCode":null,"errorMessage":"unable to determine domain for noreply email","messagePattern":"unable to determine domain for noreply email","errorType":"http","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/internal/controller/campaign/campaign_v1_form.go","lineNumber":111,"sourceCode":"\n// sendConfirmationEmail sends a confirmation email to the newly subscribed user\nfunc sendConfirmationEmail(ctx context.Context, email, name string) error {\n\t// Get the base domain to construct noreply email\n\tbaseURL := domains.GetBaseURL()\n\tif baseURL == \"\" {\n\t\treturn fmt.Errorf(\"base URL not configured\")\n\t}\n\n\t// Extract domain from base URL\n\tdomain := \"\"\n\tif u, err := url.Parse(baseURL); err == nil && u.Hostname() != \"\" {\n\t\tdomain = u.Hostname()\n\t} else {\n\t\t// Fallback: try to get from environment\n\t\tif hostname, err := public.DockerEnv(\"BILLIONMAIL_HOSTNAME\"); err == nil && hostname != \"\" {\n\t\t\tdomain = hostname\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"unable to determine domain for noreply email\")\n\t\t}\n\t}\n\n\t// Construct noreply email address\n\tnoreplyEmail := fmt.Sprintf(\"noreply@%s\", domain)\n\n\t// Create email sender\n\tsender, err := mail_service.NewEmailSenderWithLocal(noreplyEmail)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create email sender: %w\", err)\n\t}\n\tdefer sender.Close()\n\n\t// Create confirmation email content\n\tsubject := \"Welcome! Your subscription has been confirmed\"\n\tcontent := fmt.Sprintf(`\n<!DOCTYPE html>\n<html>","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/controller/campaign/campaign_v1_form.go#L93-L129","documentation":"RetrieveMountpointByUser resolves the mountpoint for a username by looking up the OS user and deriving the mountpoint from the prefix of HomeDir before '/home/'. It throws 'specified user not valid' when the user exists but their home directory does not contain '/home/', meaning the function cannot infer a mountpoint. This is a BillionMail-specific convention, not a standard Unix constraint.","triggerScenarios":"Calling RetrieveMountpointByUser with a user whose HomeDir is not under /home (e.g. root with /root, service users with /var/lib/... or /nonexistent, nologin system users).","commonSituations":"Running the code in minimal/containerized environments where users are system accounts with unusual home dirs; passing 'root'; LDAP/NIS users whose home paths differ.","solutions":["Pass a regular user whose home directory lives under /home/ (e.g. 'www')","If the user must be supported, create it with usermod -d /home/<name> <name>","Adjust RetrieveMountpointByUser to handle home dirs outside /home/ if your environment requires it","Handle the returned error explicitly and fall back to a default mountpoint ('/')"],"exampleFix":"// before\nmp, err := public.RetrieveMountpointByUser(\"root\") // HomeDir=/root -> error\n// after\nmp, err := public.RetrieveMountpointByUser(\"www\") // HomeDir=/home/www -> ok","handlingStrategy":"validation","validationCode":"if u, err := user.Lookup(username); err == nil && !strings.Contains(u.HomeDir, \"/home/\") {\n\treturn fmt.Errorf(\"user %s has home %q outside /home; pick a regular user\", username, u.HomeDir)\n}","typeGuard":null,"tryCatchPattern":"mp, err := public.RetrieveMountpointByUser(username)\nif err != nil {\n\tif strings.Contains(err.Error(), \"specified user not valid\") {\n\t\tmp = \"/\" // fall back to root mountpoint or reject the request\n\t}\n\treturn err\n}","preventionTips":["Only pass regular users whose home is under /home/ (e.g. 'www'), never 'root' or service accounts","Document that RetrieveMountpointByUser assumes /home-based home directories","Create users with homeadd -d /home/<name> when provisioning","Fall back to a default mountpoint instead of failing hard in containerized environments"],"tags":["filesystem","user","mountpoint","linux"],"backgroundTag":"invalid-user-home-dir","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}