nocobase/nocobase · error

Incorrect email format

Error message

Incorrect email format

What it means

The email transform validates each imported email value against a permissive regex before persisting it and throws when the value does not match. Empty/whitespace-only values are passed through untouched. This is thrown as a plain Error whose message is already translated via ctx.t, surfacing to the import UI as a row-level failure.

Source

Thrown at packages/plugins/@nocobase/plugin-action-import/src/server/utils/transform.ts:24

 * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
 * For more information, please refer to: https://www.nocobase.com/agreement.
 */

import { dayjs, str2moment } from '@nocobase/utils';
import * as math from 'mathjs';
import { namespace } from '../../';

export async function _({ value, field }) {
  return value;
}

export async function email({ value, field, ctx }) {
  if (!value?.trim()) {
    return value;
  }
  const emailReg = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
  if (!emailReg.test(value)) {
    throw new Error(ctx.t('Incorrect email format', { ns: namespace }));
  }
  return value;
}

export async function password({ value, field, ctx }) {
  if (value === undefined || value === null) {
    throw new Error(ctx.t('password is empty', { ns: namespace }));
  }
  return `${value}`;
}

export async function o2o({ value, column, field, ctx }) {
  const { dataIndex, enum: enumData } = column;
  const repository = ctx.db.getRepository(field.options.target);
  let enumItem = null;
  if (enumData?.length > 0) {
    enumItem = enumData.find((e) => e.label === value);
  }

View on GitHub (pinned to fa42722fef)

Solutions

  1. Correct the offending cell to a plain valid email like user@example.com
  2. Trim leading/trailing characters and remove display-name or bracket wrappers
  3. Check for invisible characters (zero-width spaces, RTL marks) when the value looks valid; retype the value
  4. If the source data is bulk-invalid, clean it in the spreadsheet with a validation formula before import

Example fix

// before
email: "Alice <alice@example.com>"
// after
email: "alice@example.com"
Defensive patterns

Strategy: validation

Validate before calling

const emailReg = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
if (value?.trim() && !emailReg.test(value)) {
  throw new Error(`Invalid email in row: ${value}`);
}

Type guard

function isValidEmail(value: unknown): value is string {
  return typeof value === 'string' && /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(value);
}

Try / catch

try {
  await importer.import(file);
} catch (err) {
  if (String(err.message).includes('Incorrect email format')) {
    // surface row location to user and skip/fix the row
  }
  throw err;
}

Prevention

When it happens

Trigger: An imported cell contains text like 'alice', 'a@', 'alice at x.com', or has stray characters/unicode the regex rejects, while being non-empty. The regex requires local-part@domain.tld with each dot-separated label non-empty.

Common situations: Copy-pasted contact lists with display names ('Alice <a@x.com>'), trailing punctuation ('a@x.com.'), concatenated columns, or placeholder values ('N/A') in the email column.

Related errors


AI-assisted analysis of nocobase/nocobase@fa42722fef (2026-09-01). Data as JSON: /api/errors/ca2b6d162fb08afb. Report an issue: GitHub.