{"record":{"id":"e290c97ea69d2a62","repo":"nocobase/nocobase","slug":"password-is-empty","errorCode":null,"errorMessage":"password is empty","messagePattern":"password is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/plugins/@nocobase/plugin-action-import/src/server/utils/transform.ts","lineNumber":31,"sourceCode":"\nexport async function _({ value, field }) {\n  return value;\n}\n\nexport async function email({ value, field, ctx }) {\n  if (!value?.trim()) {\n    return value;\n  }\n  const emailReg = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\\.[a-zA-Z0-9_-])+/;\n  if (!emailReg.test(value)) {\n    throw new Error(ctx.t('Incorrect email format', { ns: namespace }));\n  }\n  return value;\n}\n\nexport async function password({ value, field, ctx }) {\n  if (value === undefined || value === null) {\n    throw new Error(ctx.t('password is empty', { ns: namespace }));\n  }\n  return `${value}`;\n}\n\nexport async function o2o({ value, column, field, ctx }) {\n  const { dataIndex, enum: enumData } = column;\n  const repository = ctx.db.getRepository(field.options.target);\n  let enumItem = null;\n  if (enumData?.length > 0) {\n    enumItem = enumData.find((e) => e.label === value);\n  }\n  const val = await repository.findOne({ filter: { [dataIndex[1]]: enumItem?.value ?? value } });\n  return val;\n}\nexport const oho = o2o;\nexport const obo = o2o;\n\nexport async function o2m({ value, column, field, ctx }) {","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/nocobase/nocobase/blob/fa42722fefe44265490dff2c27d79e2882bce4fa/packages/plugins/@nocobase/plugin-action-import/src/server/utils/transform.ts#L13-L49","documentation":"The password transform requires an explicit password cell in the import data when the password field is being imported and throws if the value is undefined or null. Unlike other transforms it does not tolerate absence — a password field with no value cannot be persisted safely, so import fails for that row.","triggerScenarios":"Importing users where the password column exists but the cell is empty (null/undefined after parsing), i.e. the column header is present but no value was provided for that row.","commonSituations":"Admins bulk-creating users from a template and leaving password cells blank for 'we'll set them later'; exported user data that strips password columns (exports never include real passwords) then being re-imported without filling passwords in.","solutions":["Fill in a password value for every row in the password column before importing","Remove the password column from the import mapping if you do not intend to set passwords via import","Use a placeholder policy: generate passwords in the sheet (e.g. a formula) and communicate them to users","If empty passwords are legitimate, change the import config to skip the password field entirely rather than import it with nulls"],"exampleFix":"// before\n| name  | password |\n| alice |          |\n// after\n| name  | password   |\n| alice | S3cure!Pass|","handlingStrategy":"validation","validationCode":"// before import, ensure every row has a password when the field is mapped\nconst rowsWithoutPassword = rows.filter((r) => r.password === undefined || r.password === null);\nif (rowsWithoutPassword.length) {\n  throw new Error(`${rowsWithoutPassword.length} rows are missing a password`);\n}","typeGuard":"function hasPassword(row: { password?: unknown }): row is { password: string | number } {\n  return row.password !== undefined && row.password !== null;\n}","tryCatchPattern":"try {\n  await importer.import(file);\n} catch (err) {\n  if (String(err.message).includes('password is empty')) {\n    // abort and ask user to fill the password column\n  }\n  throw err;\n}","preventionTips":["Fill every password cell in the template before upload","Do not map the password field if you don't intend to set passwords via import","Use generated placeholder passwords and force reset on first login","Validate the sheet with a 'blank cell' check before submitting"],"tags":["validation","password","import"],"backgroundTag":"empty-required-field","analyzedSha":"fa42722fefe44265490dff2c27d79e2882bce4fa","analyzedAt":"2026-09-01T00:54:31.202Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}