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

**Code:** `Illegal arguments: undefined, string` · **Category:** Authentication · **Seen on:** REST API

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/auth/bcrypt-illegal-arguments)
