{"record":{"id":"0b75a20f09c78163","repo":"crowdsecurity/crowdsec","slug":"unknown-challenge-difficulty-q-expected-disabled","errorCode":null,"errorMessage":"unknown challenge difficulty %q (expected disabled, low, medium, high, or impossible)","messagePattern":"unknown challenge difficulty %q \\(expected disabled, low, medium, high, or impossible\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/appsec/challenge/challenge.go","lineNumber":281,"sourceCode":"\t}\n}\n\n// DifficultyFromLevel resolves a named level (\"low\", \"medium\", \"high\") to\n// a PoW difficulty in leading zero bits. Case-insensitive.\nfunc DifficultyFromLevel(level string) (int, error) {\n\tswitch strings.ToLower(level) {\n\tcase \"disabled\":\n\t\treturn PowDifficultyDisabled, nil\n\tcase \"low\":\n\t\treturn PowDifficultyLow, nil\n\tcase \"medium\":\n\t\treturn PowDifficultyMedium, nil\n\tcase \"high\":\n\t\treturn PowDifficultyHigh, nil\n\tcase \"impossible\":\n\t\treturn PowDifficultyImpossible, nil\n\tdefault:\n\t\treturn 0, fmt.Errorf(\"unknown challenge difficulty %q (expected disabled, low, medium, high, or impossible)\", level)\n\t}\n}\n\n// Difficulty returns the current default PoW difficulty (in leading zero bits).\nfunc (c *ChallengeRuntime) Difficulty() int {\n\treturn c.powDifficulty\n}\n\n// SetDifficulty sets the default PoW difficulty from a named level.\nfunc (c *ChallengeRuntime) SetDifficulty(level string) error {\n\tbits, err := DifficultyFromLevel(level)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tc.powDifficulty = bits\n\n\treturn nil","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/appsec/challenge/challenge.go#L263-L299","documentation":"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.","triggerScenarios":"Thrown at pkg/appsec/challenge/challenge.go:281 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use one of: disabled, low, medium, high, impossible (case-insensitive) in the appsec challenge difficulty config"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}