What the agent does
copy-webpack-plugin 6.0.0 changed its constructor. Up to 5.x it took an array of patterns; from 6 it takes { patterns: [...] }, and a config that still passes the array fails as soon as webpack loads it with ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema. followed by one line per pattern: options[0] misses the property 'patterns'. The message then prints the shape it wanted, which is also the list of per-pattern keys the new release accepts: from, to, context, globOptions, filter, toType, force, info, flatten, transform, cacheTransform, transformPath and noErrorOnMissing. The 5.x ignore key is not on it.
In a browser extension like plibither8/markdown-new-tab, package.json pins nothing exactly: copy-webpack-plugin ^5.0.0, webpack ^4.29.4, webpack-cli ^3.2.3, html-webpack-plugin ^3.2.0 and size-plugin ^1.1.2, with npm run build running webpack --mode=production and a Travis file that runs xo and the build on Node 8. webpack.config.js lines 34 to 50 build new CopyWebpackPlugin([...]) with four patterns: src files matched by * with ignore: '*.js', src/static to static, the webextension-polyfill bundle and the activate-power-mode script, and the dist folder that results is what the release scripts upload to the Chrome and Firefox stores.
The agent builds the project as the lockfile pins it first, webpack 4.35.0 and copy-webpack-plugin 5.0.3: on Node 22 that needs NODE_OPTIONS=--openssl-legacy-provider for webpack 4, and the build then prints the size-plugin line for index.js and leaves the tree clean. It then tries what a developer would: npm install copy-webpack-plugin@latest is refused by npm with an ERESOLVE error, because 13.0.1 peer-depends on webpack 5.1 and runs on Node 18.12 or newer. The release a webpack 4 project can take is 6.x, whose peer range still allows webpack 4.37, so the agent installs webpack 4.47.0 and copy-webpack-plugin 6.4.1 and reproduces the ValidationError, thrown from new CopyPlugin at line 34 of the config with four misses the property 'patterns' entries.
The rewrite is two edits: the array becomes { patterns: [...] }, and the first pattern's ignore: '*.js' becomes globOptions: { ignore: ['**/*.js'] }, since ignore left the pattern schema and glob options moved under their own key. The rebuilt output lists index.js, markdown.css, browser-polyfill.min.js and activate-power-mode.js with their sizes, and dist holds those plus index.html, manifest.json and static, the same set the 5.x build produced. The agent compares the two dist listings file by file, so a pattern that silently stopped matching shows up as a missing file rather than as a store rejection later, and it records that moving to copy-webpack-plugin 13 means moving to webpack 5 first.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "This webpack build fails with ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema, after copy-webpack-plugin was upgraded. Install from the lockfile and build once as pinned, recording the output and the list of files in the output directory; if webpack 4 needs NODE_OPTIONS=--openssl-legacy-provider on the current Node, say so. Then upgrade copy-webpack-plugin to the newest release whose peer range the project's webpack satisfies, checking with npm view, and reproduce the error. Rewrite the plugin call to the patterns form and move any option that left the pattern schema, such as ignore, to its new place under globOptions, reading the accepted keys from the error message and the installed plugin's schema. Rebuild and diff the output directory listing against the first build; every file must still be there. Report which copy-webpack-plugin release the project can reach without moving to webpack 5. Open a pull request with the config change, both build outputs and the directory diff.",
"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 changes webpack.config.js, package.json and the lockfile. The description opens with the ValidationError as the upgraded plugin printed it, line number included, and the npm refusal that explains why the newest release was not the target. Below that are the two build outputs and a side-by-side listing of the output directory before and after, with no file missing.
The session's record keeps the install commands with their resolved versions, each build and the directory listings, so a reviewer who wants to see that the polyfill and the power-mode script still land in the bundle reads the listing rather than taking the summary's word for it.
Before merging, a reviewer checks that the globOptions.ignore pattern excludes the same files the old ignore did, that the release scripts that upload the output directory still find the manifest where they expect it, and that the Node version in CI can run the new plugin.
Run it on every Dependabot pull request for copy-webpack-plugin
The error arrives with a dependency bump, so the useful moment is when the bump is opened. 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 copy-webpack-plugin 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, and the run rewrites the config against the release in that pull request's lockfile and pushes the fix onto the same branch or opens its own.
From your own server the same request goes to POST /o/{org}/sessions with the repository in resources. 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?
The edit is small; the proof that the copied files are all still there is what takes the time. It means a build on the pinned versions, a build on the new ones and a file-by-file comparison of the output, on a Node release that webpack 4 did not anticipate. In a Rush sandbox the agent does that on its own disk and keeps both listings as part of the run, and the machine is gone when the run ends.
What comes back is checkable: the transcript holds the exact error, the peer-dependency refusal, both builds and the directory diff. A team with several webpack 4 projects on the same plugin 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 does npm refuse to install the latest copy-webpack-plugin?
Because 13.0.1 declares a peer dependency on webpack 5.1 or newer and needs Node 18.12, and the example project is on webpack 4. npm 7 and later stop on that conflict with ERESOLVE. The agent picks the newest release whose peer range includes the installed webpack, which is 6.x for a webpack 4 project, and names 13 as the target once webpack moves.
Where did the ignore option go?
Under globOptions. From copy-webpack-plugin 6 a pattern's matching is configured with globOptions: { ignore: [...] }, and the patterns are globs against the pattern's context, so *.js becomes **/*.js. The error message lists the accepted keys and ignore is not among them, which is how the agent confirms the move before editing.
How do I know every file still gets copied?
The agent lists the output directory after the pinned build and again after the rewrite and diffs the two. In the example both hold the bundle, the stylesheet, the polyfill, the power-mode script, the generated HTML, the manifest and the static folder. A pattern that stopped matching would show as a missing file in that diff.
Does this build need an old Node?
webpack 4 fails on Node 17 and later without NODE_OPTIONS=--openssl-legacy-provider, and the agent sets it for both builds and says so in the pull request. It does not change the project's Node target; that belongs with the move to webpack 5.
More jobs like this: Fix a bug from an alert
- Fix "Could not find method compile() for arguments" in Gradle 7 and Later (Gradle)
- Fix `Call to undefined function create_function()` after moving to PHP 8 (PHP)
- Fix "TypeError: crypto.createCipher is not a function" on Node.js 22 (Node.js crypto)
- Fix TypeError: crypto.hash Is Not a Function After a Vite 7 Upgrade (Vite)
- Fix "AttributeError: 'Cursor' object has no attribute 'count'" after a PyMongo upgrade (PyMongo)
- Fix "d3.scale.linear is not a function" after upgrading D3 past version 3 (D3)