crowdsecurity/crowdsec · error
unable to update bouncer type and version in database: %w
Error message
unable to update bouncer type and version in database: %w
What it means
UpdateBouncerTypeAndVersion wraps a failed ent update of a bouncer's type and version columns. Called from the LAPI Middleware so the database reflects the authenticating bouncer's reported type/version; any update failure is wrapped with this message.
Source
Thrown at pkg/database/bouncers.go:167
return fmt.Errorf("unable to update bouncer stream pull in database: %w", err)
}
return nil
}
func (c *Client) UpdateBouncerIP(ctx context.Context, ipAddr string, id int) error {
_, err := c.Ent.Bouncer.UpdateOneID(id).SetIPAddress(ipAddr).Save(ctx)
if err != nil {
return fmt.Errorf("unable to update bouncer ip address in database: %w", err)
}
return nil
}
func (c *Client) UpdateBouncerTypeAndVersion(ctx context.Context, bType string, version string, id int) error {
_, err := c.Ent.Bouncer.UpdateOneID(id).SetVersion(version).SetType(bType).Save(ctx)
if err != nil {
return fmt.Errorf("unable to update bouncer type and version in database: %w", err)
}
return nil
}
func (c *Client) QueryBouncersInactiveSince(ctx context.Context, t time.Time) ([]*ent.Bouncer, error) {
return c.Ent.Bouncer.Query().Where(
// poor man's coalesce
bouncer.Or(
bouncer.LastPullLT(t),
bouncer.And(
bouncer.LastPullIsNil(),
bouncer.CreatedAtLT(t),
),
),
).All(ctx)
}
View on GitHub (pinned to 909b515798)
Solutions
- Verify the bouncer entry still exists before/after update (ent.IsNotFound)
- Inspect the wrapped driver error and retry transient failures
- Check SQLite lock contention and WAL mode
- Confirm the middleware's context isn't cancelled by client disconnect
Defensive patterns
Strategy: try-catch
Validate before calling
if n, _ := c.Ent.Bouncer.Query().Where(bouncer.ID(id)).Count(ctx); n == 0 { return } Try / catch
if err := c.UpdateBouncerTypeAndVersion(ctx, bType, version, id); err != nil {
log.Warnf("bouncer %d type/version update failed: %v", id, err)
} Prevention
- Treat this as non-fatal telemetry in middleware; never fail auth on it
- Log and retry once on transient errors
- Keep prune policies from racing with active bouncers
- Update type/version on registration only if updates keep failing
When it happens
Trigger: Bouncer row deleted concurrently (e.g. by prune), database locked/unreachable, or context cancelled during the UPDATE.
Common situations: A newly upgraded bouncer re-authenticates while cscli/prune removes stale entries; SQLite contention on busy LAPI instances.
Related errors
- unable to update bouncer ip address in database: %w
- unable to delete bouncers: %w
- unable to update machine last pull in database: %w
- unable to update bouncer stream pull in database: %w
- while getting allowlist %s: %s
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/f09fb15a596d1aac.
Report an issue: GitHub.