kataras/iris · error
path is required
Error message
path is required
What it means
errPathMissing is the unexported sentinel returned by the BoltDB session database's New when the path argument is empty. BoltDB is a file-based store, so the path must include both directory and filename (e.g. sessions/store.db) and cannot be blank.
Source
Thrown at sessions/sessiondb/boltdb/database.go:33
// DefaultFileMode used as the default database's "fileMode"
// for creating the sessions directory path, opening and write
// the session boltdb(file-based) storage.
var (
DefaultFileMode = 0755
)
// Database the BoltDB(file-based) session storage.
type Database struct {
table []byte
// Service is the underline BoltDB database connection,
// it's initialized at `New` or `NewFromDB`.
// Can be used to get stats.
Service *bolt.DB
logger *golog.Logger
}
var errPathMissing = errors.New("path is required")
// New creates and returns a new BoltDB(file-based) storage
// instance based on the "path".
// Path should include the filename and the directory(aka fullpath), i.e sessions/store.db.
//
// It will remove any old session files.
func New(path string, fileMode os.FileMode) (*Database, error) {
if path == "" {
golog.Error(errPathMissing)
return nil, errPathMissing
}
if fileMode == 0 {
fileMode = os.FileMode(DefaultFileMode)
}
// create directories if necessary
if err := os.MkdirAll(filepath.Dir(path), fileMode); err != nil {View on GitHub (pinned to 7bedaf55a0)
Solutions
- Pass a full path including filename, e.g. boltdb.New("sessions/store.db").
- Validate the config value at startup and return a clear error before calling New.
- Ensure the parent directory exists and the process has write permissions.
- If you already have an open bolt.DB, use NewFromDB instead of New.
Example fix
// before
db, err := boltdb.New("") // error: path is required
// after
db, err := boltdb.New("sessions/store.db") Defensive patterns
Strategy: validation
Validate before calling
const p = os.Getenv("SESSION_BOLTDB_PATH")
if p == "" || filepath.Ext(p) != ".db" {
log.Fatal("SESSION_BOLTDB_PATH must be a full path incl. filename, e.g. sessions/store.db")
}
db, err := boltdb.New(p) Prevention
- Always include the filename in the BoltDB path (fullpath, not directory).
- Validate config at startup, before New.
- Ensure the target directory exists and is writable.
When it happens
Trigger: Calling boltdb.New("") while registering the session database — typically when the path comes from an unset env var, empty config struct field, or omitted CLI flag.
Common situations: Deployment where the DB_FILE/SESSION_DB_PATH env var is missing; config file lacking the path key; using the wrong constructor (NewFromDB expects an open *bolt.DB instead of a path).
Related errors
- directoryPath is empty
- not implemented yet
- session not found
- empty regex expression
- unexpected file extension: %s
AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30).
Data as JSON: /api/errors/d2cbe4bfd98489d4.
Report an issue: GitHub.