benbjohnson/litestream · error

database does not exist: %s

Error message

database does not exist: %s

What it means

Guard in 'litestream reset' Run: os.Stat reports the database file does not exist at the given path and no matching config entry provides it. Fires when the user passes a path to a non-existent SQLite database; reset only operates on existing databases.

Source

Thrown at cmd/litestream/reset.go:69

			return fmt.Errorf("cannot read config: %w", configErr)
		}

		// Find database config
		for _, dbc := range config.DBs {
			expandedPath := dbc.Path
			if !filepath.IsAbs(expandedPath) {
				expandedPath, _ = filepath.Abs(expandedPath)
			}
			if expandedPath == dbPath {
				dbConfig = dbc
				break
			}
		}
	}

	// If no config found, check if database file exists
	if _, err := os.Stat(dbPath); os.IsNotExist(err) {
		return fmt.Errorf("database does not exist: %s", dbPath)
	} else if err != nil {
		return fmt.Errorf("cannot access database: %w", err)
	}

	// Create DB instance
	var db *litestream.DB
	if dbConfig != nil {
		db, err = NewDBFromConfig(dbConfig)
		if err != nil {
			return fmt.Errorf("cannot create database from config: %w", err)
		}
	} else {
		db = litestream.NewDB(dbPath)
	}

	// Check if meta path exists
	metaPath := db.MetaPath()
	if _, err := os.Stat(metaPath); os.IsNotExist(err) {

View on GitHub (pinned to 4ed7a308f6)

Solutions

  1. Check the database path spelling (it is made absolute before checking)
  2. Pass -config so the database is matched via its configured path
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cmd/litestream/reset.go:69 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06). Data as JSON: /api/errors/3e91afb0001b5ef1. Report an issue: GitHub.