semaphoreui/semaphore · error

database configuration not found

Error message

database configuration not found

What it means

Inside PrintDbInfo, after GetDialect succeeded, the dialect value still matches no known driver in the print switch, so Semaphore panics with 'database configuration not found'. This is an internal invariant: a dialect was resolved but is neither mysql, boltdb, postgres, nor sqlite.

Solutions

  1. Correct the top-level `dialect` value to one of: mysql, postgres, sqlite (boltdb prints a warning but is unsupported for connections)
  2. Remove the `dialect` field and let GetDialect infer it from the configured database section
  3. Verify the config file actually loaded (a stale Config struct can hold an old dialect value)

Example fix

// before (config.json)
{"dialect": "mariadb", ...}
// after
{"dialect": "mysql", ...}
Defensive patterns

Strategy: validation

Validate before calling

var known = map[string]bool{"mysql": true, "postgres": true, "sqlite": true, "bolt": true}
if cfg.Dialect != "" && !known[cfg.Dialect] {
    return fmt.Errorf("unknown dialect %q", cfg.Dialect)
}

Try / catch

defer func() {
    if r := recover(); r != nil {
        if err, ok := r.(error); ok && err.Error() == "database configuration not found" {
            log.Println("no valid database configured")
            return
        }
        panic(r)
    }
}()

Prevention

When it happens

Trigger: PrintDbInfo receives a dialect string that passes GetDialect (conf.Dialect set to a non-empty unknown value like 'foo') but fails the switch, hitting `default: panic(fmt.Errorf("database configuration not found"))`.

Common situations: Custom/garbage value in the top-level `dialect` config field that bypasses inference but is not a supported constant; partially-migrated config files.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of semaphoreui/semaphore@1774ccb71a (2026-09-07). Data as JSON: /api/errors/cdc1b63d06ce7d16. Report an issue: GitHub.

Appendix: source

Thrown at util/config.go:2100

func (conf *ConfigType) PrintDbInfo() {
	// Get the database dialect
	dialect, err := conf.GetDialect()
	if err != nil {
		panic(err)
	}

	// Print database connection information based on the dialect
	switch dialect {
	case DbDriverMySQL:
		fmt.Printf("MySQL %v@%v %v\n", conf.MySQL.GetUsername(), conf.MySQL.GetHostname(), conf.MySQL.GetDbName())
	case DbDriverBolt:
		fmt.Printf("BoltDB not supported\n")
	case DbDriverPostgres:
		fmt.Printf("Postgres %v@%v %v\n", conf.Postgres.GetUsername(), conf.Postgres.GetHostname(), conf.Postgres.GetDbName())
	case DbDriverSQLite:
		fmt.Printf("SQLite %v@%v %v\n", conf.SQLite.GetUsername(), conf.SQLite.GetHostname(), conf.SQLite.GetDbName())
	default:
		panic(fmt.Errorf("database configuration not found"))
	}
}

func (conf *ConfigType) GetDialect() (dialect string, err error) {
	if conf.Dialect == "" {
		switch {
		case conf.MySQL.IsPresent():
			dialect = DbDriverMySQL
		case conf.Postgres.IsPresent():
			dialect = DbDriverPostgres
		case conf.SQLite.IsPresent():
			dialect = DbDriverSQLite
		default:
			err = errors.New("database configuration not found")
		}
		return
	}

View on GitHub (pinned to 1774ccb71a)