argoproj/argo-workflows · error
no active session
Error message
no active session
What it means
SessionProxy.With found sp.sess == nil: the proxy was constructed (or reset after a failed reconnect) without ever holding an open database session. Without a session it cannot execute fn, so it returns this error instead of a nil-pointer panic.
Source
Thrown at util/sqldb/session.go:277
return false
}
// With executes with a db Session
func (sp *SessionProxy) With(ctx context.Context, fn func(db.Session) error) error {
logger := logging.RequireLoggerFromContext(ctx)
sp.mu.RLock()
if sp.closed {
sp.mu.RUnlock()
logger.Warn(ctx, "session proxy is closed")
return fmt.Errorf("session proxy is closed")
}
sess := sp.sess
sp.mu.RUnlock()
if sess == nil {
return fmt.Errorf("no active session")
}
err := fn(sess)
if err == nil {
return nil
}
// If it's not a network error or inside a tx do not retry
if !sp.isNetworkError(err) || sp.insideTransaction {
return err
}
if reconnectErr := sp.reconnectIfStale(ctx, sess); reconnectErr != nil {
return fmt.Errorf("operation failed and reconnection failed: %w", reconnectErr)
}
sp.mu.RLock()
sess = sp.sessView on GitHub (pinned to 35bff19146)
Solutions
- Fix the root DB connection failure (check persistence config: postgres/mysql host, port, credentials, secrets) — With will work once a session is established.
- Call Reconnect(ctx) explicitly after fixing connectivity and check its error before issuing queries.
- Verify NewPersistence/connect completed successfully at startup; fail fast instead of serving traffic with a sessionless proxy.
- Wrap calls so this error triggers a delayed retry with backoff rather than failing the workflow operation permanently.
Example fix
// before
offload := sqldb.NewOfflineOffloadOrNumericIDRepo(...)
err := offload.Save(ctx, wf) // "no active session"
// after
proxy := sqldb.NewSessionProxy(...)
if err := proxy.Reconnect(ctx); err != nil {
logger.Error(ctx, "db reconnect failed", err)
return err
}
err := proxy.With(ctx, func(s db.Session) error { return save(s, wf) }) Defensive patterns
Strategy: retry
Validate before calling
if proxy.Session() == nil {
if err := proxy.Reconnect(ctx); err != nil {
return fmt.Errorf("database session unavailable: %w", err)
}
} Type guard
func hasActiveSession(sp *sqldb.SessionProxy) bool { return sp.Session() != nil } Try / catch
err := proxy.With(ctx, fn)
if err != nil && strings.Contains(err.Error(), "no active session") {
if rerr := proxy.Reconnect(ctx); rerr == nil {
err = proxy.With(ctx, fn)
}
} Prevention
- Fail fast at startup if the initial DB connect fails instead of serving with a sessionless proxy.
- Validate persistence config before constructing the proxy.
- Call Reconnect and check its error after any connectivity incident before issuing queries.
- Monitor logs for repeated reconnection failures — sess stays nil until one succeeds.
When it happens
Trigger: Calling With (directly or via Save/Get/List/ListOldOffloads/ListWorkflowsLabelKeys/ListWorkflowsLabelValues) before the initial connect() succeeded, or after a reconnect attempt left sp.sess nil because connect() kept failing.
Common situations: Misconfigured persistence (bad credentials/host) at startup so the initial session never opens but the proxy object still exists; reconnectLocked failing on every retry leaving sess nil; races during proxy initialization.
Related errors
- session proxy is closed
- operation %v is not supported
- offload node status is not supported
- getting archived workflows not supported
- deleting archived workflows not supported
AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03).
Data as JSON: /api/errors/04423f72ac1f2a94.
Report an issue: GitHub.