fix(deps): upgrade langium to 4.2 to drop vulnerable lodash-es (#2704)#2709
Conversation
Installing `@zenstackhq/cli` pulled in vulnerable `lodash-es` transitively through `chevrotain@11 <- langium@3.5.0` (GHSA-r5fr-rjxr-66jc, GHSA-f23m-r3pf-42rh, GHSA-xxjr-mmjv-4gpg). `chevrotain@12` (used by langium 4) dropped the `lodash-es` dependency, and `chevrotain-allstar` now uses the patched `lodash-es@^4.18.1`, so upgrading langium eliminates all three advisories at the source for consumers. Ports the language stack to langium 4 breaking changes: - generated AST type consts are now objects -> use `.$type` - ScopeComputation: computeExports -> collectExportedSymbols, processNode/PrecomputedScopes -> addLocalSymbol/MultiMap - CstNode `.parent`/`.element` -> `.container`/`.astNode` - `Reference.ref` is now required -> synthetic refs add `ref: undefined` - ServiceRegistry lost its singleton fallback: fix in-memory format URI to `memory:///schema.zmodel` so the `.zmodel` extension resolves - add `@types/node` + `types: ["node"]` to the language package (node globals previously came transitively via a chevrotain-11 dep removed by chevrotain 12) Drops the now-redundant `lodash-es` override (resolves to 4.18.1 on its own); keeps the `lodash` override which still bumps a dev-only vulnerable pin. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude finished @ymc9's task —— View job PR Review: Langium 4.2 UpgradeI've completed my review of this Langium upgrade PR. Here's my comprehensive analysis: Todo List:
Overall Assessment ✅This is a well-executed upgrade that addresses critical security vulnerabilities while maintaining functionality. The migration from Langium 3.5.0 → 4.2.4 is comprehensive and properly handled. Security Analysis ✅Excellent security improvement:
Code Quality Assessment ✅Breaking Changes Handled Correctly:
Critical Fix Identified ✅ServiceRegistry URI Resolution (
Infrastructure Updates ✅TypeScript Configuration (
Performance Considerations ✅
Potential Issues & Recommendations 🔍Low Risk Items:
Recommendations:
Validation Results ✅
Final Verdict: APPROVE ✅This is a high-quality security-focused upgrade that:
The code quality is consistent with the existing codebase, and the security benefits significantly outweigh the migration complexity. |
📝 WalkthroughWalkthroughThis PR upgrades Langium from 3.5.0 to 4.2.4, migrates language service APIs to newer patterns, systematically converts AST factory and code generation to use ChangesLangium 4.x upgrade and AST pattern refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
package.json (1)
17-17: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winPin
packageManagerto the mandated pnpm version.Line 17 sets
pnpm@10.33.0, but the repo rule requirespnpm@10.12.1. Please pin it to avoid workspace/CI toolchain drift.Suggested fix
- "packageManager": "pnpm@10.33.0", + "packageManager": "pnpm@10.12.1",As per coding guidelines,
{package.json,.npmrc}: Use pnpm for package management with workspaces, pinned to version pnpm@10.12.1.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@package.json` at line 17, Update the packageManager field in package.json to the mandated pinned version by replacing the current "packageManager": "pnpm@10.33.0" entry with "packageManager": "pnpm@10.12.1" so the repo uses the required pnpm toolchain; ensure the packageManager key remains present and correctly quoted.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@package.json`:
- Line 17: Update the packageManager field in package.json to the mandated
pinned version by replacing the current "packageManager": "pnpm@10.33.0" entry
with "packageManager": "pnpm@10.12.1" so the repo uses the required pnpm
toolchain; ensure the packageManager key remains present and correctly quoted.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a60dc91d-aa72-480c-b137-15803951681d
⛔ Files ignored due to path filters (4)
packages/language/src/generated/ast.tsis excluded by!**/generated/**packages/language/src/generated/grammar.tsis excluded by!**/generated/**packages/language/src/generated/module.tsis excluded by!**/generated/**pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (17)
package.jsonpackages/auth-adapters/better-auth/src/schema-generator.tspackages/cli/src/actions/check.tspackages/cli/src/actions/db.tspackages/cli/src/actions/generate.tspackages/language/package.jsonpackages/language/src/document.tspackages/language/src/factory/attribute.tspackages/language/src/factory/declaration.tspackages/language/src/factory/expression.tspackages/language/src/factory/primitives.tspackages/language/src/zmodel-code-generator.tspackages/language/src/zmodel-linker.tspackages/language/src/zmodel-scope.tspackages/language/tsconfig.jsonpackages/sdk/src/prisma/prisma-schema-generator.tspnpm-workspace.yaml
Problem
Installing
@zenstackhq/cliimmediately brings in vulnerablelodash-es(#2704), pulled in transitively throughchevrotain@11 ← langium@3.5.0:_.template_.unset/_.omitThe pre-existing root override only covered the oldest advisory and, being a workspace override, never reached consumers anyway.
Fix
Upgrade langium
3.5.0→4.2.4(langium-cli4.2.1).chevrotain@12(used by langium 4) dropped thelodash-esdependency entirely, andchevrotain-allstar@0.4.xuses the patchedlodash-es@^4.18.1. This eliminates all three advisories at the source for consumers — no override needed.Verified the whole tree now resolves only
lodash-es@4.18.1andlodash@4.18.1(both patched).Langium 4 porting
.$type(factories,switchcases,match().with(), comparisons,includes)computeExports→collectExportedSymbols;processNode/PrecomputedScopes→addLocalSymbol/MultiMap.parent/.element→.container/.astNodeReference.refis now required → synthetic refs addref: undefinedmemory:///schema.zmodelso the.zmodelextension resolves (this was the root cause of a large cascade of CLI test failures)@types/node+"types": ["node"]to@zenstackhq/language— node globals previously arrived transitively via a chevrotain-11 dependency that chevrotain 12 removedOverride cleanup
lodash-esoverride (resolves to4.18.1on its own)lodashoverride — still bumps a dev-only vulnerable pin (chevrotain@10.5.0via@better-auth/cli), no effect on published consumersValidation
migrate resettests fail only due to Prisma's "invoked by AI agent" guardrail in this environment — unrelated)Closes #2704
🤖 Generated with Claude Code
Summary by CodeRabbit
Chores
Refactor