Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Registering without a password returns a 500 instead of telling you what is missing

Aperta Adatta ai principianti
#191 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
express, typescript

Direzione di ricerca

Inizia da apps/http-server/src/controllers/authController.ts e confronta il controllo dei campi obbligatori del gestore della registrazione con quello del gestore dell’accesso. Aggiungi test per i campi mancanti e vuoti, quindi verifica che l’esempio curl restituisca 400 indicando il campo mancante e che la registrazione valida continui a funzionare. L’issue suggerisce anche di controllare quizController e inviteController per individuare lacune simili nella validazione del corpo della richiesta.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Backend first issue bug good first issue help wanted

The register handler reads the body and goes straight to work:

// apps/http-server/src/controllers/authController.ts
export const userRegisterController = async (req: Request, res: Response) => {
    try {
        const { name, email, password } = req.body;

        const isUserExisted = await prisma.user.findUnique({ where: { email } })
        if (isUserExisted) return errorResponse(res, 400, "Email is already existed..")

        const hashedPassword = await bcrypt.hash(password, 10);   // throws when undefined

There is no presence check, so a missing field reaches bcrypt.hash(undefined, 10), which throws into the catch and returns a generic 500.

Confirmed against the live API:

POST /api/v1/auth/register  {"name":"t","email":"..."}     # no password
→ 500 {"success":false,"error":"Internal Server Error..."}

The sibling login handler in the same file already does it right:

if (!email || !password) return errorResponse(res, 400, "All fields are required...");
Why it matters

A 500 says "the server is broken". A 400 says "you forgot the password". Anyone integrating with the API, or debugging a form that failed to send a field, is sent looking in the wrong place entirely — and 500s are what you page on, so this also adds noise to any error monitoring.

What a fix looks like

The smallest version is the same guard login uses. Better, since zod ^4.3.6 is already a dependency: validate the shape properly and say which field is wrong, not just that something is.

Worth checking the other controllers for the same gap while you are there — quizController and inviteController have endpoints that read req.body directly too. If you find more, mention them in the PR; fixing them all in one change is fine as long as the description lists them.

Definition of done
curl -X POST .../api/v1/auth/register -H "Content-Type: application/json" -d "{\"email\":\"[email protected]\"}"
# → 400, naming the missing field
  • No request with a missing or empty field can reach bcrypt.hash
  • A valid registration still works exactly as before

Good first issue: a few lines, with a working example of the right pattern directly above it in the same file.

Lingua principale
TypeScript
Stelle
21
Fork
7
Merge medio
3h 39m
PR unite (30g)
16

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TheCodeHeist-Coder/Rexial

Tutte le issue di TheCodeHeist-Coder/Rexial

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.