{"record":{"id":"cfe6029991559eb3","repo":"payloadcms/payload","slug":"invalid-database-type-given-valid-types-are-ob","errorCode":null,"errorMessage":"Invalid database type given. Valid types are: ${Object.values(dbChoiceRecord).map((dbChoice) => dbChoice.value).join(', ')}","messagePattern":"Invalid database type given\\. Valid types are: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/create-payload-app/src/lib/select-db.ts","lineNumber":49,"sourceCode":"    title: 'SQLite',\n    value: 'sqlite',\n  },\n  'vercel-postgres': {\n    dbConnectionPrefix: 'postgres://postgres:<password>@127.0.0.1:5432/',\n    title: 'Vercel Postgres',\n    value: 'vercel-postgres',\n  },\n}\n\nexport async function selectDb(\n  args: CliArgs,\n  projectName: string,\n  template?: ProjectTemplate,\n): Promise<DbDetails> {\n  let dbType: DbType | symbol | undefined = undefined\n  if (args['--db']) {\n    if (!Object.values(dbChoiceRecord).some((dbChoice) => dbChoice.value === args['--db'])) {\n      throw new Error(\n        `Invalid database type given. Valid types are: ${Object.values(dbChoiceRecord)\n          .map((dbChoice) => dbChoice.value)\n          .join(', ')}`,\n      )\n    }\n    dbType = args['--db'] as DbType\n  } else if (template?.dbType) {\n    // If the template has a pre-defined database type, use that\n    dbType = template.dbType\n  } else {\n    dbType = await p.select<{ label: string; value: DbType }[], DbType>({\n      initialValue: 'mongodb',\n      message: `Select a database`,\n      options: Object.values(dbChoiceRecord).map((dbChoice) => ({\n        label: dbChoice.title,\n        value: dbChoice.value,\n      })),\n    })","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/create-payload-app/src/lib/select-db.ts#L31-L67","documentation":"selectDb throws when --db is passed but its value is not one of the dbChoiceRecord values (d1-sqlite, mongodb, postgres, sqlite, vercel-postgres). The message enumerates the accepted values, and the check uses exact equality against dbChoice.value.","triggerScenarios":"Running create-payload-app with --db <type> where <type> is misspelled, deprecated, or not supported by this CLI version (e.g. --db mysql, --db mongo).","commonSituations":"Using a database identifier from a different docs version; typo like 'postgre' or 'mongo'; passing a value with extra whitespace.","solutions":["Use one of the exact values printed in the error message (d1-sqlite, mongodb, postgres, sqlite, vercel-postgres).","If you omitted --db, let the interactive prompt choose, or rely on the template's predefined dbType.","Update create-payload-app if you expect a database type added in a newer release.","Strip any surrounding whitespace/quotes from the --db argument."],"exampleFix":"// before\n$ npx create-payload-app my-app --db postgre\n\n// after\n$ npx create-payload-app my-app --db postgres","handlingStrategy":"validation","validationCode":"import { dbChoiceRecord } from './select-db.js'\n\nfunction assertValidDb(value: string) {\n  const valid = Object.values(dbChoiceRecord).map((c) => c.value)\n  if (!valid.includes(value as never)) {\n    throw new Error(`--db must be one of: ${valid.join(', ')}`)\n  }\n}","typeGuard":"const dbTypes = ['d1-sqlite', 'mongodb', 'postgres', 'sqlite', 'vercel-postgres'] as const\ntype DbType = (typeof dbTypes)[number]\nfunction isDbType(x: string): x is DbType {\n  return (dbTypes as readonly string[]).includes(x)\n}","tryCatchPattern":null,"preventionTips":["Copy the --db value exactly from the error message.","Omit --db to use the interactive prompt when unsure.","Script against the dbChoiceRecord values rather than guessing."],"tags":["create-payload-app","cli","validation","database","config"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}