# Fix the body-parser "provide extended option" Deprecation Warning in Express

Yes. An agent finds each urlencoded() call with no options, reads your forms to choose extended true or false, and shows requests parse as before.

[Run this on Rush](https://cloud.getrush.ai/run/fix-body-parser-extended-option-deprecation/body-parser/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

Every time the server starts it prints a line such as `body-parser deprecated undefined extended: provide extended option at app.js:25:20`. The warning points at a call to `bodyParser.urlencoded()` made with no options. The parser has two modes for form bodies, a simple one and an extended one that understands nested field names, and it wants the application to say which. The usual advice is to paste in `{ extended: true }` and move on. That silences the line, and it can be the wrong value. The choice changes what `req.body` looks like, so it should come from reading the forms.

jquemada/quiz-2015, a small Express quiz application, has the call in `app.js`: `app.use(bodyParser.json());` on line 24 and `app.use(bodyParser.urlencoded());` on line 25, with `"body-parser": "~1.8.1"` and `"express": "~4.9.0"` in `package.json`. The agent then reads what posts to the server. `views/quizes/_form.ejs` names its inputs `quiz[pregunta]` and `quiz[respuesta]`, `views/user/_form.ejs` uses `user[username]` and `user[password]`, and `views/comments/new.ejs` uses `comment[texto]`. The controllers depend on that nesting: `quiz_controller.js` builds a model from `req.body.quiz`, `user_controller.js` from `req.body.user`, and `comment_controller.js` reads `req.body.comment.texto`. Only the login form in `session_controller.js` reads flat fields.

That settles the value. With body-parser 1.8.4, the release the `~1.8.1` range installs, a body of `a[b]=1&c=2` parses to `{"a":{"b":"1"},"c":"2"}` when no option is given and when `extended` is `true`. With `extended: false` it parses to `{"a[b]":"1","c":"2"}`. In this application the second form would leave `req.body.quiz` as `undefined` and every create and edit action would throw. So the agent writes `bodyParser.urlencoded({ extended: true })`, which keeps today's behaviour, and says why in the pull request. In a codebase whose forms are all flat it would choose `false` and say that instead.

It proves the change with requests, not by reading the diff. Before the edit it starts the app, posts a nested body and a flat body to a route that accepts forms, and saves the parsed result along with the startup log. After the edit it repeats both and compares: same parsed objects, no deprecation line. Where the project has no test for form handling, the agent adds one small test that posts a nested body and asserts on the nested object, so the next person to touch this option learns immediately if they flip it. It checks for other callers as well, including `express.urlencoded()` with no options, which prints the identical warning on Express 4.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "On startup this Express app prints the warning `body-parser deprecated undefined extended: provide extended option`. Find every call to bodyParser.urlencoded() and express.urlencoded() without an explicit extended option, in the app and in any router or middleware module. Do not just add extended: true. Decide the value from the code: list every HTML form, template, client-side request and test that sends application/x-www-form-urlencoded data, and every handler that reads req.body, and say whether any field name uses bracket syntax (user[name], items[]) or any handler expects nested objects or arrays. If any does, use extended: true; if none does, use extended: false. State the evidence either way. Before editing, install dependencies from the lockfile if there is one, start the app, and record the startup log and the parsed req.body for one nested and one flat urlencoded POST. If the app cannot start without a database or other service, exercise the parser through a minimal script that mounts the same middleware with the project's installed body-parser version, and say that you did. Make the change, repeat the same requests and show that the parsed bodies are identical and the deprecation line is gone. If there is no test covering form parsing, add one that posts a nested body and asserts the nested result. Do not upgrade body-parser or Express, and do not replace body-parser with express.urlencoded in this pull request. Report any other deprecation lines printed at startup without fixing them. Open a pull request with the list of forms and handlers you read, the before and after output, and the reason for the value you chose.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

A pull request that changes one line per call site and, when there was no coverage, adds one test. The description lists the forms and handlers the agent read, grouped by whether they use nested names, and ends that list with the conclusion: nested data is posted, so `extended: true`; or it is not, so `extended: false`.

Then come the two captures. The startup log from before shows the deprecation line with its file and position; the one from after does not. The parsed bodies for the nested and flat requests are printed for both, and they match. If the application could not be started in the sandbox because it needs a database, the description states that the parser was exercised through a minimal script using the project's installed body-parser, so the reader knows what kind of proof it is.

The reviewer checks the list against their own knowledge of the app. A mobile client or a partner integration that posts forms will not appear in the repository, and it may depend on one mode or the other. If such a caller exists, the safest merge is the value that matches current behaviour, which for body-parser 1.x is `true`.

## Run it on every Linear issue labelled tech-debt

Startup warnings are the kind of small issue that sits in a backlog. In the Project that holds the repository, an automation with a `linear` trigger on `linear.issue.labeled` and the label your team uses for cleanup starts one run for each issue that receives it. The trigger adds the issue after the automation's prompt; it does not fill a placeholder, so write the prompt to say that the task is described in the issue that follows. Connect Linear once in the console under Settings → Connections.

To start runs from your own tooling, send the request above with your API key and put the issue in `resources` next to the repository, as `https://linear.app/<workspace>/issue/<ID>`; Rush reads it through your Linear connection and places it in the prompt. A `request_id` that is a UUID v5 of the issue id keeps a retried call from starting a second run.

## Why run it on Rush?

The fix is one object literal, and that is why it is rarely done carefully. The careful version means reading every form and handler, starting the server, sending real requests and comparing the results. An agent does that reading without skipping the dull templates, and it does the comparison in a sandbox where starting an old Express app does not disturb anything on your machine.

The record is useful later. Six months on, someone will wonder whether `extended` can be switched to `false` to drop a dependency. The pull request already holds the list of nested field names and the parsed output for each mode, and the session transcript holds the commands that produced them.

## Frequently asked questions

### Should extended be true or false?

Use `true` if any form field uses bracket names such as `user[name]` or `tags[]`, or any handler expects nested objects from a form. Use `false` if every field is flat. In body-parser 1.x, leaving the option out behaves like `true`, so `true` is the value that preserves current behaviour.

### Does the warning mean something is broken?

No. Requests are parsed exactly as before; the library is telling you that it will not keep guessing. It becomes a real problem when you upgrade, because the default changes. Setting the option now removes that risk.

### What happens when I upgrade to Express 5 or body-parser 2?

The warning disappears and the default flips. With body-parser 2.2.0, and with `express.urlencoded()` on Express 5.3.0, the body `a[b]=1&c=2` parses to a flat object with the key `a[b]`. An app that relied on nesting without stating `extended: true` breaks quietly at that point.

### Can I hide the message without changing code?

Setting the environment variable `NO_DEPRECATION=body-parser` suppresses it, and `TRACE_DEPRECATION=body-parser` prints a stack trace showing which call caused it. Hiding it leaves the upgrade risk in place. The trace is useful when the call is inside a module you did not write.

### I use express.urlencoded(), not body-parser. Is this the same?

Yes. Express 4 ships body-parser inside it, and `express.urlencoded()` with no options prints the same line on Express 4.22.3. The agent searches for both spellings and fixes them the same way.

## More body-parser jobs

- [Replace body-parser With express.json() in an Express App](https://getrush.ai/run/migrate-body-parser-to-express-json/body-parser/)

## More jobs like this: Turn a Linear label into a PR

- [Fix "AttributeError: module 'cgi' has no attribute 'escape'" on Python 3.8 and Later](https://getrush.ai/run/fix-cgi-escape-attribute-error/cgi/)
- [Fix "Deprecated: Creation of dynamic property is deprecated" in PHP 8.2](https://getrush.ai/run/fix-creation-of-dynamic-property-deprecated/php/)
- [Fix "DeprecationWarning: datetime.datetime.utcnow() is deprecated" on Python 3.12](https://getrush.ai/run/fix-datetime-utcnow-deprecation-warning/datetime/)
- [Fix "[DEP0147] DeprecationWarning: fs.rmdir(path, { recursive: true }) will be removed" in Node.js](https://getrush.ai/run/fix-fs-rmdir-recursive-deprecation-warning/nodejs/)
- [Fix "AttributeError: 'HTMLParser' object has no attribute 'unescape'" in Python 3.9+](https://getrush.ai/run/fix-htmlparser-unescape-attribute-error/html-parser/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
