gotify/server · error

unsupported dialect:

Error message

unsupported dialect: 

What it means

New() in database/database.go fails when the dialect argument passed by the caller is not one of the gorm-supported dialects (sqlite, mysql, postgres, etc.). The empty message indicates the dialect string was empty or unrecognized, so gorm.Open cannot select a driver and initialization aborts before any DB handle exists.

Source

Thrown at database/database.go:50

// New creates a new wrapper for the gorm database framework.
func New(dialect, connection, defaultUser, defaultPass string, strength int, createDefaultUserIfNotExist bool, now func() time.Time) (*GormDatabase, error) {
	createDirectoryIfSqlite(dialect, connection)

	dbLogger := logger.New(gormLogWriter{}, logger.Config{
		SlowThreshold:             200 * time.Millisecond,
		LogLevel:                  logger.Warn,
		IgnoreRecordNotFoundError: true,
		Colorful:                  isatty.IsTerminal(os.Stderr.Fd()),
	})
	gormConfig := &gorm.Config{
		Logger:                                   dbLogger,
		DisableForeignKeyConstraintWhenMigrating: true,
		TranslateError:                           true,
		NowFunc:                                  now,
	}

	var db *gorm.DB
	err := errors.New("unsupported dialect: " + dialect)

	switch dialect {
	case "mysql":
		db, err = gorm.Open(mysql.Open(connection), gormConfig)
	case "postgres":
		db, err = gorm.Open(postgres.Open(connection), gormConfig)
	case "sqlite3":
		db, err = gorm.Open(sqlite.Open(connection), gormConfig)
	}

	if err != nil {
		return nil, err
	}

	sqldb, err := db.DB()
	if err != nil {
		return nil, err
	}

View on GitHub (pinned to 14bfc25627)

Solutions

  1. Pass a supported dialect string (e.g. "sqlite3", "mysql", "postgres") from the configuration in serve or the test setup
  2. Validate the dialect value against the known list before calling New and fail with a clear config error
  3. Log or surface the offending dialect value in the error message to make misconfiguration obvious
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at database/database.go:50 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gotify/server@14bfc25627 (2026-09-05). Data as JSON: /api/errors/7c70773976dbd7d8. Report an issue: GitHub.