crowdsecurity/crowdsec · error

nil start_at

Error message

nil start_at

What it means

Guard in UpdateCommunityBlocklist: alert.StartAt (the decision validity start timestamp) must be set because it is used to compute overlapping decisions to delete; a nil StartAt would produce an invalid database row, so the alert is rejected.

Source

Thrown at pkg/database/alerts.go:199

		return nil
	}); err != nil {
		return "", err
	}

	return "", nil
}

// UpdateCommunityBlocklist is called to update either the community blocklist (or other lists the user subscribed to)
// it takes care of creating the new alert with the associated decisions, and it will as well deleted the "older" overlapping decisions:
// 1st pull, you get decisions [1,2,3]. it inserts [1,2,3]
// 2nd pull, you get decisions [1,2,3,4]. it inserts [1,2,3,4] and will try to delete [1,2,3,4] with a different alert ID and same origin
func (c *Client) UpdateCommunityBlocklist(ctx context.Context, alertItem *models.Alert) (int, int, int, error) {
	if alertItem == nil {
		return 0, 0, 0, errors.New("nil alert")
	}

	if alertItem.StartAt == nil {
		return 0, 0, 0, errors.New("nil start_at")
	}

	startAtTime, err := time.Parse(time.RFC3339, *alertItem.StartAt)
	if err != nil {
		return 0, 0, 0, fmt.Errorf("start_at field time '%s': %w: %w", *alertItem.StartAt, err, ParseTimeFail)
	}

	if alertItem.StopAt == nil {
		return 0, 0, 0, errors.New("nil stop_at")
	}

	stopAtTime, err := time.Parse(time.RFC3339, *alertItem.StopAt)
	if err != nil {
		return 0, 0, 0, fmt.Errorf("stop_at field time '%s': %w: %w", *alertItem.StopAt, err, ParseTimeFail)
	}

	ts, err := time.Parse(time.RFC3339, *alertItem.StopAt)
	if err != nil {

View on GitHub (pinned to 909b515798)

Solutions

  1. Ensure the alert model is fully populated (StartAt set) before calling UpdateCommunityBlocklist
  2. Validate CAPI/PAPI payloads for a missing start_at field
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/database/alerts.go:199 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/c51a1b73640d96fe. Report an issue: GitHub.