crowdsecurity/crowdsec · error

while checking if we should force pull blocklist %s: %w

Error message

while checking if we should force pull blocklist %s: %w

What it means

updateBlocklist wraps errors from ShouldForcePullBlocklist, which decides whether the blocklist must be re-pulled by checking stored alert/decision freshness. Any non-NotFound DB error from those checks surfaces through this message, with the blocklist name in the text.

Source

Thrown at pkg/apiserver/apic.go:951

	return false, nil
}

func (a *apic) updateBlocklist(ctx context.Context, client *apiclient.ApiClient, blocklist *modelscapi.BlocklistLink, addCounters map[string]map[string]int, forcePull bool) error {
	if blocklist.Scope == nil {
		log.Warningf("blocklist has no scope")
		return nil
	}

	if blocklist.Duration == nil {
		log.Warningf("blocklist has no duration")
		return nil
	}

	if !forcePull {
		_forcePull, err := a.ShouldForcePullBlocklist(ctx, blocklist)
		if err != nil {
			return fmt.Errorf("while checking if we should force pull blocklist %s: %w", *blocklist.Name, err)
		}

		forcePull = _forcePull
	}

	blocklistConfigItemName := fmt.Sprintf("blocklist:%s:last_pull", *blocklist.Name)

	var (
		lastPullTimestamp string
		err               error
	)

	if !forcePull {
		lastPullTimestamp, err = a.dbClient.GetConfigItem(ctx, blocklistConfigItemName)
		if err != nil {
			return fmt.Errorf("while getting last pull timestamp for blocklist %s: %w", *blocklist.Name, err)
		}
	}

View on GitHub (pinned to 909b515798)

Solutions

  1. Check the inner error and DB status (`cscli db doctor`).
  2. Restart crowdsec to reset DB connections after an outage.
  3. Enable WAL mode for SQLite.
  4. As a workaround, force a pull (`cscli capi pull` / next cycle) once DB is healthy.
Defensive patterns

Strategy: fallback

Validate before calling

// verify DB reachable: cscli db doctor

Try / catch

if !forcePull {
    _forcePull, err := a.ShouldForcePullBlocklist(ctx, blocklist)
    if err != nil {
        log.Warnf("force-pull check failed (%v), defaulting to force pull", err)
        forcePull = true
    } else {
        forcePull = _forcePull
    }
}

Prevention

When it happens

Trigger: UpdateBlocklists iterates subscribed blocklists; for one of them ShouldForcePullBlocklist returns an error because the alert or decision lookup failed at the DB layer.

Common situations: Database outage during a pull cycle, SQLite lock contention, blocklist name referencing stale data after manual DB cleanup.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06). Data as JSON: /api/errors/4807f0f33c585de1. Report an issue: GitHub.