crowdsecurity/crowdsec · error

unknown challenge difficulty %q (expected disabled, low, med

Error message

unknown challenge difficulty %q (expected disabled, low, medium, high, or impossible)

What it means

SetChallengeDifficultyPerRequest/SetDifficulty passed a difficulty level string that is not one of the named PoW difficulties (disabled, low, medium, high, impossible; matched case-insensitively). The guard echoes the bad value with the accepted set; the challenge difficulty could not be resolved to a leading-zero-bits count.

Source

Thrown at pkg/appsec/challenge/challenge.go:281

	}
}

// DifficultyFromLevel resolves a named level ("low", "medium", "high") to
// a PoW difficulty in leading zero bits. Case-insensitive.
func DifficultyFromLevel(level string) (int, error) {
	switch strings.ToLower(level) {
	case "disabled":
		return PowDifficultyDisabled, nil
	case "low":
		return PowDifficultyLow, nil
	case "medium":
		return PowDifficultyMedium, nil
	case "high":
		return PowDifficultyHigh, nil
	case "impossible":
		return PowDifficultyImpossible, nil
	default:
		return 0, fmt.Errorf("unknown challenge difficulty %q (expected disabled, low, medium, high, or impossible)", level)
	}
}

// Difficulty returns the current default PoW difficulty (in leading zero bits).
func (c *ChallengeRuntime) Difficulty() int {
	return c.powDifficulty
}

// SetDifficulty sets the default PoW difficulty from a named level.
func (c *ChallengeRuntime) SetDifficulty(level string) error {
	bits, err := DifficultyFromLevel(level)
	if err != nil {
		return err
	}

	c.powDifficulty = bits

	return nil

View on GitHub (pinned to 909b515798)

Solutions

  1. Use one of: disabled, low, medium, high, impossible (case-insensitive) in the appsec challenge difficulty config
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/appsec/challenge/challenge.go:281 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/0b75a20f09c78163. Report an issue: GitHub.