Skip to content

fix(deploy): add cheerio to srv-mcp deps + widen bundle-externals guard - #2537

Merged
jung-thomas merged 1 commit into
DEVfrom
worktree-mcp-auth-multipackage
Sep 29, 2026
Merged

jung-thomas merged 1 commit into
DEVfrom
worktree-mcp-auth-multipackage

Conversation

@jung-thomas

Copy link
Copy Markdown
Contributor

Why

tutorials-srv-mcp crashed at CF boot with ERR_MODULE_NOT_FOUND: Cannot find package 'cheerio' imported from srv/lib/_shared/core.bundle.mjs. The esbuild core bundle imports cheerio as an external, but srv-mcp/package.json never declared it, so the CF nodejs buildpack didn't install it.

The T22 externals guard was too narrow — it only checked @sap*-scoped externals, so third-party externals like cheerio slipped through and only surfaced as a runtime boot crash.

What

  • srv-mcp/package.json — add "cheerio": "^1.2.0" (matches root + srv-qa).
  • scripts/check-bundle-externals-declared.cjs — widen from @sap*-prefix-only to all bare external imports: skip Node builtins (require('module').builtinModules + node: strip) and relative imports; check every remaining bare import against the consuming module's package.json deps. srv (no own package.json) checks against root via pkgOverride.
  • scripts/__tests__/check-bundle-externals-declared.test.ts — 33 tests (was 18); adds an isBareExternal suite, a cheerio-missing violation test, and a 2026-09-29: srv-mcp missing cheerio regression pair (pre-fix catches it, post-fix passes).

Verification

  • node scripts/bundle-shared.cjs && node scripts/check-bundle-externals-declared.cjs → exit 0.
  • External-vs-deps audited across all 3 modules (srv / srv-qa / srv-mcp); cheerio was the only missing external — no others surfaced.
  • vitest run → 70 files, 1049 tests passed.
  • EOL: all 3 changed files CRLF at HEAD, matching origin/DEV baseline (no LF→CRLF flip).

Last deploy blocker before the T13 PKCE acceptance gate.

…d to all bare externals

srv-mcp crashed at boot on DEV with ERR_MODULE_NOT_FOUND for 'cheerio' because
core.bundle.mjs and mcp.bundle.mjs import cheerio transitively (external, not
inlined by esbuild) but srv-mcp/package.json did not declare it.

This is the same class of bug as the 2026-09-28 @sap-ai-sdk/orchestration incident
in srv-qa, but for a third-party package that the narrow guard (which only checked
@sap-ai-sdk/* and @sap/* prefixes) missed.

Changes:
1. srv-mcp/package.json: add "cheerio": "^1.2.0" (matches root + srv-qa version).
2. scripts/check-bundle-externals-declared.cjs: widen the guard from @sap-ai-sdk/
   and @sap/ prefixes to ALL bare external import specifiers in every *.bundle.mjs,
   excluding Node.js builtins (detected via require('module').builtinModules with
   node: prefix stripping) and relative imports. The regex now matches only lines
   that begin with `import` (the esbuild external form) to avoid false positives
   from `from "..."` inside string literals in the bundle body. The guard also
   handles `srv` (which has no own package.json) by falling back to the root-level
   package.json via a pkgOverride in MODULE_DIRS.
3. scripts/__tests__/check-bundle-externals-declared.test.ts: update existing 18
   tests to reflect widened scope; add isBareExternal tests; add regression test
   for the srv-mcp cheerio incident (pre-fix catches it, post-fix passes).

Widened guard run against all 3 modules after bundle rebuild: exit 0.
@jung-thomas
jung-thomas merged commit f0f91f3 into DEV Sep 29, 2026
4 checks passed
@jung-thomas
jung-thomas deleted the worktree-mcp-auth-multipackage branch September 29, 2026 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant