A Free Interactive Platform by @satyatechgeek

AI writes the code. You review it.

Interactive challenges for catching the bugs that Copilot, Cursor, and Claude Code sneak into your pull requests.

easyHallucinated APIs
Interactive Sample

The phantom module

A junior developer asked a chatbot to write a script that generates a cryptographically secure random identifier. The AI generated the following code, claiming it uses Node.js standard libraries. What is the issue here?

generate-id.js
const crypto = require('crypto');

function generateUserSessionId() {
  // Generate a random ID using standard crypto module
  const rawToken = crypto.generateRandomToken(32);
  return rawToken.toString('hex');
}

console.log(generateUserSessionId());

What is the primary bug in the AI-generated code?

crypto.generateRandomToken is not a standard Node.js API method; it should be crypto.randomBytes.
rawToken.toString() does not accept 'hex' as an encoding format; it only supports 'utf8'.
The crypto module must be installed via npm first; it is not a built-in Node.js module.
The function generates synchronous blockages and should be wrapped in an async/await block.

Sign in with GitHub to check your answer.

40

Challenges

7

Categories

₹0

Free Forever