AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

`@Next/Codemod Upgrade` Writes Pnpm Overrides To Nested Workspace In Pnpm V11 Monorepos

When upgrading a Next.js TypeScript app inside a pnpm v11 monorepo, the codemod creates a nested `pnpm-workspace.yaml` in the app directory instead of updating the root workspace file, causing `pnpm install` to fail with workspace dependency resolution errors.

highConfidence 95%Next.jsPages RouterHydrationReact Server ComponentsAffected V@next/codemod 16.4.0-Canary.35

Origin Analysis

The codemod writes pnpm v11 overrides relative to `cwd`, creating a new `pnpm-workspace.yaml` in the app folder. This marks the app as a separate workspace root, severing it from the monorepo siblings and breaking `pnpm install`.
1. Clone a pnpm v11 monorepo with an app depending on a workspace package via `workspace:*` and having `@types/react` / `@types/react-dom` installed. 2. Run `pnpm install` at root. 3. `cd` into the app directory. 4. Execute `pnpm dlx @next/codemod@canary upgrade latest` (or `pnpm exec next upgrade`). 5. Observe the created `apps/web/pnpm-workspace.yaml` and the install failure `ERR_PNPM_WORKSPACE_PKG_NOT_FOUND`.

Fixing Code Block

Edge Case Audit

This patch uses YAML parse/stringify, which may strip comments or custom formatting from an existing `pnpm-workspace.yaml`. Concurrent codemod runs could cause race conditions. If the root file contains complex YAML anchors or unknown keys, they might be lost. Rollback: back up the root `pnpm-workspace.yaml` before applying, and restore from version control if corruption occurs. Ensure the `yaml` package is available or replace with an already existing YAML parser.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state