crowdsecurity/crowdsec · error
failed to parse '%s': %w
Error message
failed to parse '%s': %w
What it means
Returned by constraint.Satisfies when the version string passed in cannot be parsed by hashicorp/go-version. Used when loading bucket factories and stage files whose yaml declares a version the runtime checks against supported constraints.
Source
Thrown at pkg/cwversion/constraint/constraint.go:19
package constraint
import (
"fmt"
goversion "github.com/hashicorp/go-version"
)
const (
Parser = ">= 1.0, <= 3.0"
Scenario = ">= 1.0, <= 3.0"
API = "v1"
Acquis = ">= 1.0, < 2.0"
)
func Satisfies(strvers string, constraint string) (bool, error) {
vers, err := goversion.NewVersion(strvers)
if err != nil {
return false, fmt.Errorf("failed to parse '%s': %w", strvers, err)
}
constraints, err := goversion.NewConstraint(constraint)
if err != nil {
return false, fmt.Errorf("failed to parse constraint '%s'", constraint)
}
if !constraints.Check(vers) {
return false, nil
}
return true, nil
}
View on GitHub (pinned to 909b515798)
Solutions
- Fix the version string in the offending file to a valid format like 1.0 or 1.0.2 (the wrapped error names the unparsable string).
- Reinstall the affected hub item via cscli hub install to restore canonical file content.
- Remove or relocate the malformed custom file if it is not needed.
- Compare against a known-good item file from the official hub to see the expected version syntax.
Example fix
// before (bad file content) version: latest // after version: 1.0
Defensive patterns
Strategy: validation
Validate before calling
if _, err := goversion.NewVersion(versionStr); err != nil {
return fmt.Errorf("item version %q is not a valid version: %w", versionStr, err)
} Try / catch
ok, err := constraint.Satisfies(vers, c)
if err != nil {
log.Errorf("skipping item: %v", err)
// fall back to treating item as compatible or skip it
} Prevention
- Always declare a valid semver-ish 'version' field in custom scenarios/parsers
- Prefer installing items via cscli hub rather than hand-copying files
- Test custom configs with cscli before production deploy
- Never leave the version field empty
When it happens
Trigger: loadBucketFactoriesFromFile or processStageFile encounters a config file whose version string is missing, malformed (e.g. 'v', '1.x', non-numeric), or otherwise not a valid semver-ish version.
Common situations: Hand-edited .yaml/.txt files in the crowdsec config directory, items installed from a third-party hub with sloppy version metadata, or empty version fields in custom scenarios/parsers.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- empty cti key
- cannot use TLS with a unix socket
- user/password authentication and TLS authentication are mutu
- no listen_uri or listen_socket specified
- empty file
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/f62905d02b01eaef.
Report an issue: GitHub.