AI Fails

When the LLM gets it wrong

Last Updated: 2026-07-31

Google Search, Gemini AI Summary - A 404 at best, unencrypted HTTP more likely

I search Google for node request get local path. Its AI summary provided the following code:

          
  1. const http = require('http');
  2. http.createServer((req, res) => {
  3. // Pass a dummy base URL to parse relative request paths safely
  4. const requestUrl = new URL(req.url, `http://${req.headers.host}`);
  5. const localPath = requestUrl.pathname;
  6. console.log(localPath); // Outputs: "/users" (instead of "/users?id=123")
  7. res.end(`Path requested: ${localPath}`);
  8. }).listen(3000);

It hard coded the protocol. The correct code is:

  1. const http = require('http');
  2. http.createServer((req, res) => {
  3. // Pass a dummy base URL to parse relative request paths safely
  4. const requestUrl = new URL(req.url, `${req.protocol}://${req.headers.host}`);
  5. const localPath = requestUrl.pathname;
  6. console.log(localPath); // Outputs: "/users" (instead of "/users?id=123")
  7. res.end(`Path requested: ${localPath}`);
  8. }).listen(3000);

By "correct" I mean in the context of this example which is a pretty absurb approach.

Playing devils advocate I "should" have searched node express request get local path:

          
  1. app.get('/users/profile', (req, res) => {
  2. console.log(req.path);
  3. // Output: "/users/profile"
  4. res.send(`The requested path is: ${req.path}`);
  5. });

The point is where is the intelligence to suggest using Express in the first query response? No one should be using unencrypted HTTP as of at least a decade ago. Adding insult to injury the example uses CommonJS syntax.