Skip to content

fix(#7570): bundle DB drivers, add regression CI#7572

Merged
JohnMcLear merged 4 commits intoether:developfrom
JohnMcLear:fix/7570-ueberdb2-bundling
Apr 20, 2026
Merged

fix(#7570): bundle DB drivers, add regression CI#7572
JohnMcLear merged 4 commits intoether:developfrom
JohnMcLear:fix/7570-ueberdb2-bundling

Conversation

@JohnMcLear
Copy link
Copy Markdown
Member

Summary

Fixes #7570 (Cannot find module 'mysql2' at Docker prod startup for every non-default DB backend).

Upstream root cause: ueberdb2@5.0.45 moved the 10 DB drivers from dependencies to peerDependencies + peerDependenciesMeta.optional. Production pnpm installs skip optional peer deps, so the drivers are absent from the Docker image and require('mysql2') (etc.) crashes at first use.

Two-part fix:

  • Upstream (fix: bundle DB drivers as dependencies (fix Etherpad #7570) ueberDB#939, merged, published as ueberdb2@5.0.47) — moved the 10 drivers back from optional peerDependencies to real dependencies.
  • This PR (downstream):
    • Bumps ueberdb2 to ^5.0.47.
    • Declares all 10 drivers as direct src/package.json dependencies — defensive safety net so a future upstream drift cannot silently break Etherpad prod again.
    • Adds a new build-test-db-drivers CI job that blocks publish:
      • Presence test — the built production image must be able to require() each of the 10 drivers (@elastic/elasticsearch, cassandra-driver, mongodb, mssql, mysql2, nano, pg, redis, rethinkdb, surrealdb). Fast, deterministic regression catch for the exact UeberDB2 mysql2 dependency #7570 class.
      • MySQL smokemysql:8 service container, launch Etherpad with DB_TYPE=mysql, require / to serve. Live reproduction of the issue reporter's scenario.
      • Postgres smoke — same for postgres:16.
    • Any stage failure blocks Docker Hub / GHCR publishing.

Supersedes #7571 (thanks @copilot — the direction was right; this variant strips unrelated bumps and expands regression coverage).

Test plan

  • Upstream ueberdb2@5.0.47 published to npm
  • Local: pnpm install in a fresh clone resolves cleanly, src/ workspace picks up ueberdb2@5.0.47, all 10 drivers resolve via require()
  • CI: build-test passes
  • CI: build-test-db-drivers — presence stage 10/10 ok
  • CI: build-test-db-drivers — MySQL stage serves /
  • CI: build-test-db-drivers — Postgres stage serves /

🤖 Generated with Claude Code

JohnMcLear and others added 3 commits April 20, 2026 17:49
Spec for the upstream ueberDB fix (move 10 drivers back from optional
peer deps to dependencies) plus downstream etherpad-lite safety net
(explicit driver list + build-test-db-drivers CI job covering all 10
via presence check and MySQL+Postgres smoke tests).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Covers upstream ueberDB PR (move drivers from optional peer deps back
to dependencies, publish 5.0.46) and downstream etherpad-lite PR
(bump ueberdb2, defensive driver list, build-test-db-drivers CI job
with presence + MySQL + Postgres stages gating publish).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Bump ueberdb2 to ^5.0.47 (upstream ueberDB PR ether#939 re-bundles drivers
  as real dependencies instead of optional peer deps, fixing the class
  of Docker-prod "Cannot find module" failures).
- Declare all 10 ueberdb2 DB drivers as direct src dependencies as a
  defensive safety net against a future upstream drift.
- Add build-test-db-drivers CI job that blocks the publish job:
    * all-10-drivers presence check in the built prod image
    * end-to-end MySQL smoke (reproduces the ether#7570 repro)
    * end-to-end Postgres smoke
  Any stage failure blocks Docker Hub / GHCR publish.

Supersedes ether#7571.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JohnMcLear
Copy link
Copy Markdown
Member Author

/review

@qodo-free-for-open-source-projects
Copy link
Copy Markdown

qodo-free-for-open-source-projects bot commented Apr 20, 2026

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects
Copy link
Copy Markdown

Review Summary by Qodo

Fix #7570: bundle DB drivers, add regression CI

🐞 Bug fix ✨ Enhancement

Grey Divider

Walkthroughs

Description
• Bump ueberdb2 to ^5.0.47 to restore DB driver bundling in production Docker images
• Declare all 10 ueberdb2 DB drivers as direct src/package.json dependencies as defensive safety
  net
• Add build-test-db-drivers CI job with presence check and MySQL/Postgres smoke tests gating
  publish
• Includes comprehensive design spec and implementation plan for issue #7570 fix
Diagram
flowchart LR
  A["ueberdb2@5.0.45<br/>drivers in optional peerDeps"] -->|upstream fix| B["ueberdb2@5.0.47<br/>drivers in dependencies"]
  B -->|bump version| C["src/package.json<br/>explicit driver list"]
  C -->|verify in CI| D["build-test-db-drivers job<br/>presence + MySQL + Postgres"]
  D -->|gates| E["publish to Docker Hub/GHCR"]
Loading

Grey Divider

File Changes

1. docs/superpowers/plans/2026-04-20-issue-7570-ueberdb2-drivers.md 📝 Documentation +863/-0

Implementation plan for issue #7570 driver bundling

• Comprehensive implementation plan with 9 phases (A1–B9) covering upstream ueberDB fork and
 downstream etherpad-lite changes
• Detailed step-by-step tasks for moving drivers from optional peer deps to dependencies
• Instructions for adding CI regression tests with presence check and MySQL/Postgres smoke tests
• Includes verification steps, commit templates, and rollout order

docs/superpowers/plans/2026-04-20-issue-7570-ueberdb2-drivers.md


2. docs/superpowers/specs/2026-04-20-issue-7570-ueberdb2-drivers-design.md 📝 Documentation +222/-0

Design spec for issue #7570 driver bundling fix

• Design specification for fixing "Cannot find module 'mysql2'" Docker production startup failure
• Explains root cause: ueberdb2@5.0.45 moved drivers to optional peerDependencies
• Outlines two-part fix: upstream ueberDB driver move + downstream defensive safety net
• Details CI regression test strategy with presence check and MySQL/Postgres smoke tests

docs/superpowers/specs/2026-04-20-issue-7570-ueberdb2-drivers-design.md


3. .github/workflows/docker.yml ✨ Enhancement +123/-1

Add build-test-db-drivers CI job with regression tests

• Add new build-test-db-drivers job with MySQL and Postgres service containers
• Implement driver presence test verifying all 10 ueberdb2 drivers resolve in production image
• Add MySQL smoke test reproducing exact issue #7570 scenario with DB_TYPE=mysql
• Add Postgres smoke test with DB_TYPE=postgres for secondary backend coverage
• Extend publish job's needs: to gate on build-test-db-drivers job completion

.github/workflows/docker.yml


View more (2)
4. src/package.json 🐞 Bug fix +11/-1

Bump ueberdb2 and add explicit driver dependencies

• Bump ueberdb2 from ^5.0.45 to ^5.0.47 to use upstream driver bundling fix
• Add 10 ueberdb2 DB drivers as direct dependencies: @elastic/elasticsearch, cassandra-driver,
 mongodb, mssql, mysql2, nano, pg, redis, rethinkdb, surrealdb
• Maintain alphabetical ordering of dependencies block
• Preserve all other dependencies and configuration unchanged

src/package.json


5. pnpm-lock.yaml Dependencies +1173/-9

Regenerate lockfile for driver dependencies

• Regenerated lockfile to resolve ueberdb2@^5.0.47 and all 10 driver dependencies
• Updates transitive dependency tree for new driver entries
• Ensures production pnpm install includes all drivers without optional peer dep skipping

pnpm-lock.yaml


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects
Copy link
Copy Markdown

qodo-free-for-open-source-projects bot commented Apr 20, 2026

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

The presence test ran node from the default cwd (/opt/etherpad-lite),
but the drivers are installed under /opt/etherpad-lite/src/node_modules
by the monorepo workspace. Adding `-w /opt/etherpad-lite/src` makes
Node resolve modules from src/node_modules where pnpm places them.

Matches how the production container itself runs: `pnpm run prod` is
invoked from src/ (cross-env + node --require tsx/cjs node/server.ts).
@JohnMcLear
Copy link
Copy Markdown
Member Author

/review

@qodo-free-for-open-source-projects
Copy link
Copy Markdown

qodo-free-for-open-source-projects bot commented Apr 20, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. ueberdb2 version split 🐞 Bug ☼ Reliability
Description
src/package.json bumps ueberdb2 to ^5.0.47 but the bin workspace still pins
ueberdb2@^5.0.45, so the production Docker image installs both versions and bin/* migration
tools run against the pre-fix ueberdb2. This undermines the packaging regression fix for any
bin/* DB operations and increases the chance of reintroducing missing-driver failures if the
src-level driver safety net changes later.
Code

src/package.json[R82-86]

+    "surrealdb": "^2.0.3",
    "swagger-ui-express": "^5.0.1",
    "tinycon": "0.6.8",
    "tsx": "4.21.0",
-    "ueberdb2": "^5.0.45",
+    "ueberdb2": "^5.0.47",
Evidence
The production Docker build explicitly installs only the src and bin workspaces, so both
workspaces’ dependencies ship in the production image. After this PR, src depends on
ueberdb2@^5.0.47 but bin still depends on ^5.0.45, and the lockfile resolves them to different
versions; bin/migrateDB.ts uses ueberdb2 and calls init(), which triggers driver loading (the
documented failure mode in #7570 was require('mysql2') from ueberdb2@5.0.45).

src/package.json[32-87]
bin/package.json[9-16]
pnpm-lock.yaml[125-145]
pnpm-lock.yaml[311-329]
Dockerfile[112-116]
Dockerfile[155-182]
bin/migrateDB.ts[2-75]
docs/superpowers/specs/2026-04-20-issue-7570-ueberdb2-drivers-design.md[7-20]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`src/package.json` was bumped to `ueberdb2@^5.0.47`, but `bin/package.json` still pins `ueberdb2@^5.0.45`. Because the production Docker build installs both `src` and `bin` workspaces, the image contains two `ueberdb2` versions and the `bin/*` DB migration utilities still run against the pre-fix `ueberdb2` version.

## Issue Context
- Docker production stage limits the workspace to `src` and `bin` and runs `bin/installDeps.sh` (pnpm recursive install).
- `bin/migrateDB.ts` uses `ueberdb2` and calls `init()`, which loads the configured DB driver (the same class of failure as #7570).

## Fix Focus Areas
- bin/package.json[9-16]
- pnpm-lock.yaml[125-145]
- src/package.json[82-86]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@JohnMcLear JohnMcLear merged commit 053f6d8 into ether:develop Apr 20, 2026
16 checks passed
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.

UeberDB2 mysql2 dependency

1 participant