crowdsecurity/crowdsec · error
alert UUID is empty
Error message
alert UUID is empty
What it means
Input guard in CreateOrUpdateAlert (PAPI path): the alert item carries an empty UUID, so it cannot be looked up or inserted. Means the upstream CAPI/PAPI payload did not populate the alert's UUID field.
Source
Thrown at pkg/database/alerts.go:47
defaultLimit = 100 // default limit of element to returns when query alerts
alertCreateBulkSize = 50 // bulk size when create alerts
maxLockRetries = 10 // how many times to retry a bulk operation when sqlite3.ErrBusy is encountered
)
func rollbackOnError(tx *ent.Tx, err error, msg string) error {
if rbErr := tx.Rollback(); rbErr != nil {
log.Errorf("rollback error: %v", rbErr)
}
return fmt.Errorf("%s: %w", msg, err)
}
// CreateOrUpdateAlert is specific to PAPI : It checks if alert already exists, otherwise inserts it
// if alert already exists, it checks it associated decisions already exists
// if some associated decisions are missing (ie. previous insert ended up in error) it inserts them
func (c *Client) CreateOrUpdateAlert(ctx context.Context, machineID string, alertItem *models.Alert) (string, error) {
if alertItem.UUID == "" {
return "", errors.New("alert UUID is empty")
}
alerts, err := c.Ent.Alert.Query().Where(alert.UUID(alertItem.UUID)).WithDecisions().All(ctx)
if err != nil && !ent.IsNotFound(err) {
return "", fmt.Errorf("unable to query alerts for uuid %s: %w", alertItem.UUID, err)
}
// alert wasn't found, insert it (expected hotpath)
if ent.IsNotFound(err) || len(alerts) == 0 {
alertIDs, err := c.CreateAlert(ctx, machineID, []*models.Alert{alertItem})
if err != nil {
return "", fmt.Errorf("unable to create alert: %w", err)
}
// happy nilaway
if len(alertIDs) == 0 {
return "", fmt.Errorf("unable to create alert: no IDs returned for alert %s", alertItem.UUID)
}View on GitHub (pinned to 909b515798)
Solutions
- Regenerate or fix the PAPI payload so every alert has a UUID before calling CreateOrUpdateAlert
- Check the deserialization of the PAPI response for a missing/misnamed UUID field
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pkg/database/alerts.go:47 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/f99768a78659e6c5.
Report an issue: GitHub.