8000 Container crashes on start when DATABASE_URL is set: Cannot read properties of undefined (reading 'dbURL') · Issue #6905 · hedgedoc/hedgedoc · GitHub
[go: up one dir, main page]

Skip to content

Container crashes on start when DATABASE_URL is set: Cannot read properties of undefined (reading 'dbURL') #6905

Description

@Eudorajab1

Description

  • HedgeDoc 1.12.0 (official image) crashes straight away when the environment has a DATABASE_URL variable, even when
    CMD_DB_URL is set as well. Without DATABASE_URL the same container starts fine.
  • Platforms that give every app a DATABASE_URL (Heroku-style hosts, ours) cannot start HedgeDoc at all because of it.

Steps to reproduce

  1. Run:
    docker run --rm -e CMD_DB_URL=sqlite:///tmp/db.sqlite -e CMD_SESSION_SECRET=test -e DATABASE_URL=postgres://u:p@localhost:5432/db quay.io/hedgedoc/hedgedoc:latest
  2. It exits at once with the error in Logs below.
  3. Run the same command without "-e DATABASE_URL=...": it starts ("HTTP Server listening at 0.0.0.0:3000").

Expected behaviour

It starts, using CMD_DB_URL, the same as without DATABASE_URL.

Logs

error: uncaughtException: Cannot read properties of undefined (reading 'dbURL')
  TypeError: Cannot read properties of undefined (reading 'dbURL')
      at Object.<anonymous> (/hedgedoc/lib/config/index.js:153:15)

Config

No config file of our own: the image's /hedgedoc/config.json (which is {}) and only these environment variables:
CMD_DB_URL=sqlite:///tmp/db.sqlite
CMD_SESSION_SECRET=test
DATABASE_URL=postgres://u:p@localhost:5432/db

Your Setup

  • Host OS: Ubuntu 24.04.3 LTS, Docker 28.5.1
  • NodeJS version: v24.21.0 (the one in the image)
  • HedgeDoc version: 1.12.0 (quay.io/hedgedoc/hedgedoc:latest, 21 Oct 2026)

Additional context

  • The image's config.json is {}, so in lib/config/index.js fileConfig = require(config.json)[env] is undefined.
  • DATABASE_URL is read by lib/config/oldEnvironment.js into the legacy setting dburl.
  • The "merge legacy values" loop then reads fileConfig[keys[i]] for dbURL (line ~153) while fileConfig is undefined.
  • A guard like (fileConfig || {})[keys[i]], or defaulting fileConfig to {}, should fix it.
  • Workaround for now: don't pass DATABASE_URL to the container, only CMD_DB_URL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0