All jobs

Fix "TypeError: Missing parameter name at 1" After Upgrading to Express 5

Yes. An agent finds the wildcard route that path-to-regexp 8 rejects, rewrites it in the new syntax, and proves the catch-all still serves your single-page app.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

Express 5 ships with path-to-regexp 8, which parses route strings strictly. A bare *, the catch-all that every single-page app server has, is no longer a valid path: the parser sees a wildcard with no name and throws Missing parameter name at 1, or Missing parameter name at index 1: * in the current release, with a link to git.new/pathToRegexpError. The throw happens while routes are being registered, so the process dies on node app.js before it listens, and the stack trace points into router/lib/layer.js rather than at your file. The same strictness refuses /*, optional segments written with ?, and unescaped parentheses.

In a MERN app like TanvirSojal/QuizDen, package.json asks for express ^4.17.1 and the lock file holds 4.21.2 with path-to-regexp 0.1.12. app.js is thirty lines: cors, express.json(), express.static on client/build, app.use(routes) for the API, and on line 24 app.get("*", (req, res) => res.sendFile(... "client", "build", "index.html")) so that React Router owns every other path. The router in app/router/index.js mounts /auth, /quizzers and /quizzes under process.env.API_URI and connects Mongoose on load. Run npm install express@5 to pick up the current release, and node app.js prints the database error it always printed and then dies with the TypeError.

The agent reproduces that from the lock file first, so it knows the app starts on 4.21.2 with API_URI set, then installs Express 5 and quotes the throw with the bundled versions, path-to-regexp 8 and router 2. It greps every app.get, app.use and router.* call for the characters the new parser treats differently, *, ?, + and parentheses, and finds only the catch-all. Then it tries the spellings the new syntax allows and records which start: /{*splat}, /*splat and *splat all do, and /* does not, since a wildcard needs a name. It picks /{*splat}, the form that also matches the bare root path.

A route that registers is not yet a route that works, so the agent starts the server with a stand-in index.html in client/build and sends three requests: the API root answers 200, a deep client path such as /anything/deep returns the HTML file, and a protected API path answers 401 from the auth middleware, which shows the catch-all did not swallow API routes. It also reads the rest of the Express 5 change list against the code, req.query becoming a getter, res.redirect("back"), app.del, res.send(status) with a number, and reports that none of them appear, so the pull request names the one change the upgrade needed and the Node version Express 5 requires.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "After upgrading to Express 5 this server dies at startup with TypeError: Missing parameter name at 1 from path-to-regexp. First install from the lock file and confirm the server starts on Express 4, setting any environment variables the router reads. Then install express@5, reproduce the throw and quote it with the versions of express, path-to-regexp and router that were installed. Grep every route and mount path in app.js and the router files for characters path-to-regexp 8 treats differently: *, ?, + and parentheses. For each one, rewrite it in the new syntax, trying the allowed spellings and recording which ones start; prefer the form that also matches the bare prefix. Start the server with a placeholder index.html and send requests that prove the API root, a deep client-side path and a protected API path still answer as before, quoting the status codes. Check the code against the other Express 5 breaking changes (req.query as a getter, res.redirect('back'), app.del, res.send with a status number, req.param) and list any that apply. Update package.json to express 5 and the engines field to the Node version it needs. Open a pull request with the throw, the diff and the request transcript.",
  "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 the catch-all route string, moves express to 5 in package.json and the lock file, and sets engines.node to what Express 5 requires. The description opens with the startup transcript on Express 4, then the throw on Express 5 with the three bundled versions, so the reviewer sees the exact line that stopped the process.

Below that is the table of spellings tried, which ones registered and which one was chosen, followed by the request transcript: the API root, a deep client path returning the HTML, and a protected API path refused by the auth middleware. The session's record keeps every command and both installs.

The description ends with the breaking-change checklist for Express 5 and the result of each check against this code. For an app whose only sensitive construct is the wildcard, every row says none found; for one that reads req.query after assigning to it or redirects to back, the rows name the file and line, so the reviewer knows whether the pull request is the whole upgrade or its first step.

Run it on every dependency update pull request that fails to start

Most teams meet this error in a bot's pull request that bumps Express to 5, where the install passes and the start step dies. An automation's github trigger never fires for a bot sender, so give the automation a webhook trigger with the prompt above instead, and add a step to the workflow that runs only when the start or smoke-test step failed and its log contains Missing parameter name. Have that step post the branch name and the failing lines to the trigger's URL with Authorization: Bearer and the trigger's secret, kept as a repository secret; the posted text is placed after the saved prompt as the event.

Send an Idempotency-Key header to the trigger's URL set to the workflow run id, so a re-run of the failed job starts nothing new. The call answers 202 with the run it created, and the pull request link comes back on the session when the run ends.

The use case this job follows, with its automation and trigger: Fix a bug from an alert.

Why run it on Rush?

The fix is a few characters, and the trap is believing a server that starts is a server that works. The new syntax has several spellings that register and behave differently at the root, and a catch-all placed wrong hides every API 404 behind an HTML page. The agent runs the real server in its own sandbox and sends the requests that tell those cases apart, with the status codes kept in the session.

The upgrade also comes with a list of smaller breaking changes that are easy to skim and painful to find in production. The run reads the code against each one and reports a result per item, so the pull request says exactly how much of Express 5 this app has absorbed, and a team with many small Express services starts one run per repository with the same request.

Frequently asked questions

Why is the error in router/lib/layer.js and not in my file?

Express 5 hands every path string to path-to-regexp when the route is registered, inside the router package's layer code. The string that failed is yours; the stack trace shows where it was parsed. The message includes the offending string, which is how the agent finds the route.

Which spelling should the catch-all use?

/{*splat} matches the root and every path below it, which is what a single-page app wants. /*splat and *splat register too but treat the bare root differently. The name after the asterisk is required and arbitrary; splat is the convention in the Express 5 migration guide.

Can I stay on Express 4 and fix this later?

Yes: npm install express@4 restores the old parser, and the 4.x line still receives releases under the latest-4 tag. The agent shows the server starting from the lock file for that reason. The pull request is for the day the upgrade is wanted, and it tells you how large the rest of that upgrade is.

Does the agent need my MongoDB?

No. The router logs a connection error when the database is unreachable and the server still starts, which is enough to register routes and answer requests with a placeholder page. Routes that need data answer with the auth middleware's 401 or the database error, and the transcript shows which.

More jobs like this: Fix a bug from an alert

Keep reading