Illegal arguments: undefined, string Authentication Origin: Application & API OSI layer 7 · Application Last updated 12 Oct 2026

bcrypt error: Illegal arguments: undefined, string / data and salt arguments required / data and hash arguments required

bcrypt.compare/hash received undefined — the password field or stored hash wasn’t passed.

Exact message you may see Illegal arguments: undefined, stringIllegal arguments: string, undefineddata and salt arguments requireddata and hash arguments required
Seen on: REST API

Meaning

The request body wasn’t parsed (missing express.json()), the field name differs (pass vs password), or the user query didn’t select the password column (select: false in Mongoose/Prisma omit).

Common causes

  • Body not parsed (no JSON/body middleware)
  • Field name mismatch
  • Password hash not selected from the database
  • User not found, hash undefined

⚡ Quick fix

  1. Add express.json() and validate input
  2. Explicitly select the password field (+password)
  3. Handle user-not-found before comparing

Detailed fix by platform

JavaScript

  1. `const user = await User.findOne({ email }).select("+password"); if (!user
  2. !password) return res.status(401).end(); const ok = await bcrypt.compare(password, user.password);`

How to diagnose

  1. Inputs — Values passed to compare
  2. Query — Password selected?
  3. Body — Parsed?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

AADSTS50055 — AADSTS50055: The password is expired (Azure)AADSTS50055Account is not fully set up — Keycloak: invalid_grant — Account is not fully set up (Authentication)Account is not fully …Cannot find module — Cloud Functions: Error: Cannot find module 'X' (dependency missing at runtime) (Google Cloud / Firebase)Cannot find moduleClock skew too great — Kerberos: Clock skew too great (KRB_AP_ERR_SKEW) (Authentication)Clock skew too greatEmail not confirmed — Supabase Auth: AuthApiError: Email not confirmed (Authentication)Email not confirmedFailed to serialize user into session — Passport.js: Error: Failed to serialize user into session (Authentication)Failed to serialize u…Invalid login credentials — Supabase Auth: AuthApiError: Invalid login credentials (Authentication)Invalid login credent…invalid two-factor code — Two-factor (TOTP) code invalid / Invalid verification code (authenticator app time drift) (Authentication)invalid two-factor co…Illegal a…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.