Billionmail/BillionMail · error

domain %s does not exist

Error message

domain %s does not exist

What it means

SetSSL refuses to configure SSL for a domain that is not registered in the system. Before creating the SNI certificate, the controller calls domains.Exists(ctx, req.Domain) to confirm the domain row is present; if not, it aborts with this error. It prevents setting SSL certificates for arbitrary or mistyped domains that the mail stack does not manage.

Source

Thrown at core/internal/controller/domains/domains_v1_set_ssl.go:23

	"billionmail-core/internal/service/domains"
	"billionmail-core/internal/service/mail_service"
	"billionmail-core/internal/service/public"
	"context"
	"fmt"

	"billionmail-core/api/domains/v1"
)

func (c *ControllerV1) SetSSL(ctx context.Context, req *v1.SetSSLReq) (res *v1.SetSSLRes, err error) {
	res = &v1.SetSSLRes{}

	if ex, err1 := domains.Exists(ctx, req.Domain); !ex {
		if err1 != nil {
			res.SetError(fmt.Errorf("fail to check domain: %w", err1))
			return
		}

		res.SetError(fmt.Errorf("domain %s does not exist", req.Domain))
		return
	}

	crt := mail_service.NewCertificate()

	defer crt.Close()

	err = crt.SetSNI(public.FormatMX(req.Domain), req.Certificate, req.Key)

	if err != nil {
		res.SetError(fmt.Errorf("fail to set ssl: %w", err))
		return
	}

	_ = public.WriteLog(ctx, public.LogParams{
		Type: consts.LOGTYPE.Domain,
		Log:  "Set SSL for domain :" + req.Domain + " successfully",
		Data: req,

View on GitHub (pinned to fc36c76c05)

Solutions

  1. Add the domain first via the domains create API, then retry SetSSL.
  2. Verify the exact stored domain string (list domains) and correct req.Domain, including case and trailing characters.
  3. If 'fail to check domain' accompanies it, resolve the underlying DB error surfaced by that wrapper first.

Example fix

// before
curl -X POST /api/v1/domains/ssl -d '{"domain":"exmaple.com", ...}'
// after
curl -X POST /api/v1/domains/ssl -d '{"domain":"example.com", ...}'  // domain added beforehand
Defensive patterns

Strategy: validation

Validate before calling

// Go: confirm the domain exists before calling SetSSL
exists, err := domainsClient.Exists(ctx, domain)
if err != nil || !exists {
    return fmt.Errorf("domain %s must be added before setting SSL", domain)
}

Try / catch

if err := setSSL(domain, cert, key); err != nil {
    if strings.Contains(err.Error(), "does not exist") {
        // create the domain, then retry once
    }
    return err
}

Prevention

When it happens

Trigger: Calling the SetSSL API with req.Domain spelled differently from the stored domain (e.g. missing subdomain, trailing dot, uppercase), or calling it after the domain was deleted, or before the domain was added via the domains API.

Common situations: Typos in the domain name; using the bare zone apex when a subdomain is registered (or vice versa); a race where another admin removed the domain; operating against a fresh install where domains have not been imported yet.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05). Data as JSON: /api/errors/3ab9946a8af03010. Report an issue: GitHub.