plandex-ai/plandex · error
invalid domain: %v
Error message
invalid domain: %v
What it means
Returned from the create-org transaction when the request sets AutoAddDomainUsers=true but the authenticated user's email domain is an email-service domain (e.g. gmail.com, detected by shared.IsEmailServiceDomain). Auto-adding all users of such a public domain makes no sense and would leak org membership, so the server rejects it inside the WithTx and the handler returns 500 with this message.
Source
Thrown at app/server/handlers/orgs.go:96
}
var req shared.CreateOrgRequest
err = json.Unmarshal(body, &req)
if err != nil {
log.Printf("Error unmarshalling request: %v\n", err)
http.Error(w, "Error unmarshalling request: "+err.Error(), http.StatusInternalServerError)
return
}
var apiErr *shared.ApiError
var org *db.Org
err = db.WithTx(r.Context(), "create org", func(tx *sqlx.Tx) error {
var err error
var domain *string
if req.AutoAddDomainUsers {
if shared.IsEmailServiceDomain(auth.User.Domain) {
log.Printf("Invalid domain: %v\n", auth.User.Domain)
return fmt.Errorf("invalid domain: %v", auth.User.Domain)
}
domain = &auth.User.Domain
}
// create a new org
org, err = db.CreateOrg(&req, auth.AuthToken.UserId, domain, tx)
if err != nil {
log.Printf("Error creating org: %v\n", err)
return fmt.Errorf("error creating org: %v", err)
}
if org.AutoAddDomainUsers && org.Domain != nil {
err = db.AddOrgDomainUsers(org.Id, *org.Domain, tx)
if err != nil {
log.Printf("Error adding org domain users: %v\n", err)View on GitHub (pinned to e2d772072e)
Solutions
- Set autoAddDomainUsers to false in the CreateOrgRequest (or omit it) when authenticating with a personal email-provider account
- Use a work email on a company domain if you truly want domain-based auto-add
- If the user record is wrong, fix the account's email/domain so shared.IsEmailServiceDomain returns false
- On the server, consider returning 400/422 instead of 500 so clients can surface a clear message
Example fix
// before
{ "name": "acme", "autoAddDomainUsers": true } // authed as dev@gmail.com
// after
{ "name": "acme", "autoAddDomainUsers": false } Defensive patterns
Strategy: validation
Validate before calling
const EMAIL_DOMAINS = /@(gmail|googlemail|outlook|hotmail|yahoo|icloud|proton)\./i
if (req.autoAddDomainUsers && EMAIL_DOMAINS.test(userEmail)) {
req.autoAddDomainUsers = false // or switch to a work-email account first
}
await client.CreateOrg(req) Type guard
function canAutoAddDomainUsers(userEmail) {
return !/@(gmail|googlemail|outlook|hotmail|yahoo|icloud|proton)\./i.test(userEmail)
} Try / catch
try {
await client.CreateOrg(req)
} catch (err) {
if (String(err.message).startsWith('invalid domain')) {
req.autoAddDomainUsers = false
await client.CreateOrg(req)
}
} Prevention
- Only set autoAddDomainUsers=true when signed in with a company-domain email
- Treat public email-provider domains (gmail, outlook, etc.) as ineligible for domain auto-add
- Fix user account email/domain upstream if it wrongly maps to a consumer provider
When it happens
Trigger: POST to the create-org endpoint with {"autoAddDomainUsers": true} while authenticated with an email whose domain is a public email provider (gmail.com, outlook.com, etc.).
Common situations: Client SDK sends autoAddDomainUsers:true by default; a developer testing with a personal Gmail/Hotmail account; a misconfigured user record whose Domain field defaults to a consumer mail provider.
Related errors
- error listing orgs: %v
- error resolving org: %v
- error getting org session: %v
- invalid context index: %s
- no context found with name: %s
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/3661cb39a563d7e4.
Report an issue: GitHub.