What the agent does
Handlebars 4.6.0 stopped resolving properties that live on an object's prototype. A Mongoose document keeps its fields there: on a Todo built with mongoose 5.13, Object.keys(doc) is $__, isNew, errors, $locals and $op, and hasOwnProperty('title') is false. So a template that renders {{title}} straight from a query result prints nothing, and the server log says Handlebars: Access has been denied to resolve the property "title" because it is not an "own property" of its parent, followed by a pointer to the runtime options that control prototype access. Nothing throws; the page just comes back with empty headings, which is why people hunt for the message in the log.
In an Express app like nlharri/simple-todo-app-mongodb-express-node, nothing pins the version that bites. package.json asks for express-handlebars ^3.0.0 and mongoose ^5.0.14 with no lockfile, and express-handlebars 3.1.0 depends on handlebars ^4.1.2, so a fresh npm install resolves handlebars 4.7.8. app.js registers the engine at lines 34 to 38 with exphbs({defaultLayout: 'main'}). routes/todos.js line 15 runs Todo.find({user: req.user.id}).sort({creationDate: 'descending'}) and hands the documents to res.render('todos/index', {todos}); line 31 does the same with findOne for the edit form. views/todos/index.handlebars loops {{#each todos}} over {{title}}, {{details}}, {{dueDate}}, {{creationDate}} and {{id}}, and edit.handlebars reads {{todo.id}} and {{todo.title}}.
The agent reproduces it without a database first. It builds a document in memory with new Todo({title: 'Buy milk', details: '2 litres', user: 'u1'}), compiles the #each template with the installed handlebars, and gets [||] with the two denial messages on handlebars 4.7.8; with npm install handlebars@4.5.3 the same code renders [Buy milk|2 litres]. That pair of runs pins the cause to the version boundary rather than to the query or the schema. It then lists every res.render that receives a Mongoose document or array: the two in routes/todos.js and the user that app.js line 74 copies from req.user into res.locals, which the layout may read.
The fix the agent proposes is to hand templates plain objects. Each query gets .lean(), or each document goes through toObject({virtuals: true}) where the template needs {{id}}: a plain object has _id but no id virtual, so toObject() without virtuals renders {{id}} empty and breaks the edit and delete links. The agent checks that against the template before choosing. The alternative it describes but does not apply is the Handlebars runtime option allowProtoPropertiesByDefault, which renders the title and the id on 4.7.8 in the same test, or the @handlebars/allow-prototype-access package other Express apps add; both reopen what 4.6 closed for every template. A regression test renders todos/index.handlebars with an in-memory document and asserts the title appears, so the next upgrade cannot blank the page silently.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Pages in this Express app render Mongoose documents as blank fields, and the log prints Handlebars: Access has been denied to resolve the property. In a clean install, report which handlebars and express-handlebars versions resolve and show the denial with an in-memory document: build one with new Model({...}), compile the view's template with the installed handlebars, and print the result; then install handlebars 4.5.3 in a second directory and print the same render, so the version boundary is on record. List every res.render call that receives a Mongoose document or array, with file and line, including anything copied into res.locals. Convert each to plain objects with .lean() on the query or toObject with virtuals where the template needs id, and check every template that uses id or a virtual still gets a value. Do not enable allowProtoPropertiesByDefault and do not add @handlebars/allow-prototype-access; mention them in the pull request as the alternative. Add a test that renders the list template with an in-memory document and asserts its title appears. Run the existing tests if any and the new one, and open a pull request with the two renders and the list of changed calls.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- 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.
- 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.
- 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 touches the route files that query Mongoose, one new test file and, if the project has none, the test script in package.json. The description opens with the two renders side by side: the blank output and denial messages from the version a fresh install picks, and the filled output from handlebars 4.5.3. Below it is a table of every res.render that received a document, the file and line, and whether it now uses .lean() or toObject({virtuals: true}), with a note for each template that reads id.
The session's record holds the npm install output with the resolved versions, both render commands with their output, and the test run. A reviewer who wants to see the page rather than the test opens the session's transcript and reads the rendered HTML the test printed.
Before merging, a reviewer checks that every template reading a virtual or a method on the document still gets a value, that req.user copied into res.locals was handled or shown not to reach a template, and that no query that later calls save() on its result was switched to .lean(), since a lean result is not a document.
Run it on every Dependabot or Renovate pull request
A dependency bot opens a pull request when express-handlebars or handlebars moves, and the usual signal that something broke is a page with empty headings, not a failing build. A bot sender never fires an automation's github trigger, so give the automation a webhook trigger and add a workflow step on the bump that runs when its title names either package and posts the pull request number to the trigger's URL with Authorization: Bearer and the trigger's secret; the event lands after the prompt, so the run reads the bumped version from the pull request's lockfile diff, renders the templates the way described above, and reports whether any field went blank.
The same request works for a one-off check from your own server: send it with POST /o/{org}/sessions with the repository in resources, and give it a request_id that is a UUID v5 of the pull request number so a retried delivery returns the run that already started instead of opening a second pull request.
The use case this job follows, with its automation and trigger: Fix a bug from an alert.
Why run it on Rush?
This bug hides. The app starts, the route answers 200, and the only evidence is a log line and a page missing its text. Proving where it comes from means installing two handlebars releases, building documents against the real schema and rendering the real templates, which is tedious on a laptop and pointless on a shared CI runner. In a Rush sandbox the agent does all of it on its own disk and keeps both renders as part of the run.
What comes back is checkable rather than claimed. The transcript holds the install output with resolved versions, the blank render, the filled render and the test. A team with several Express apps forked from the same tutorial starts one run per repository with the same request, up to the key's max_concurrent limit at once, and the rest queue.
Frequently asked questions
Why did the page work last month and not now?
Because nothing pinned handlebars. The example's package.json has no lockfile and asks for express-handlebars ^3.0.0, whose 3.1.0 release depends on handlebars ^4.1.2. Any install after Handlebars 4.6.0 shipped picks up the prototype check; the code did not change, the resolved version did.
Is .lean() always the right fix?
Only for reads. A lean result is a plain object, so code that calls save(), a schema method or a virtual on it fails. The agent switches only the queries whose result goes straight to res.render, and uses toObject({virtuals: true}) where a template reads id, which a plain object does not have.
Why not just set allowProtoPropertiesByDefault?
It works: in the agent's test the runtime option renders the document's fields on 4.7.8. But it turns the check off for every template and every object, which is the exposure Handlebars 4.6 closed. The pull request names it as the quick alternative and leaves the choice to you.
Does the agent need a MongoDB to reproduce this?
No. A Mongoose document built with new Model({...}) has the same prototype layout as one returned by a query, so the agent compiles the template against an in-memory document and gets the same blank output and denial messages. The regression test uses the same approach, so it runs without a database in CI.
More jobs like this: Fix a bug from an alert
- Fix "TypeError: handler() missing 1 required positional argument: 'path'" in websockets 14 (websockets)
- Fix "TypeError: Client.__init__() got an unexpected keyword argument 'proxies'" in httpx (HTTPX)
- Fix "husky - install command is DEPRECATED" and the husky.sh deprecation in husky 9 (husky)
- Fix "AttributeError: 'ImageDraw' object has no attribute 'textsize'" in Pillow 10 (Pillow)
- Fix imageio GIFs That Play With No Frame Delay After Upgrading (mimsave duration) (imageio)
- Fix "SyntaxError: Unexpected identifier 'assert'" in rollup.config.js on Node.js 22 (Rollup)