{"record":{"id":"4dd4f643a56c9970","repo":"crowdsecurity/crowdsec","slug":"failed-to-parse-constraint-s","errorCode":null,"errorMessage":"failed to parse constraint '%s'","messagePattern":"failed to parse constraint '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cwversion/constraint/constraint.go","lineNumber":24,"sourceCode":"\tgoversion \"github.com/hashicorp/go-version\"\n)\n\nconst (\n\tParser   = \">= 1.0, <= 3.0\"\n\tScenario = \">= 1.0, <= 3.0\"\n\tAPI      = \"v1\"\n\tAcquis   = \">= 1.0, < 2.0\"\n)\n\nfunc Satisfies(strvers string, constraint string) (bool, error) {\n\tvers, err := goversion.NewVersion(strvers)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"failed to parse '%s': %w\", strvers, err)\n\t}\n\n\tconstraints, err := goversion.NewConstraint(constraint)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"failed to parse constraint '%s'\", constraint)\n\t}\n\n\tif !constraints.Check(vers) {\n\t\treturn false, nil\n\t}\n\n\treturn true, nil\n}\n","sourceCodeStart":6,"sourceCodeEnd":33,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/cwversion/constraint/constraint.go#L6-L33","documentation":"Returned by constraint.Satisfies when the constraint string itself cannot be parsed by hashicorp/go-version. The constraint constants (like Acquis = \">= 1.0, < 2.0\") are normally hardcoded, so a failure usually means code or config supplied a bad constraint expression.","triggerScenarios":"loadBucketFactoriesFromFile or processStageFile invokes Satisfies with a constraint built from config/file data that is empty or not a valid go-version constraint (e.g. missing comparison operator, stray comma).","commonSituations":"Custom item metadata with a malformed 'supported_versions' style field, corrupted hub index, or a code-level typo in a new constraint constant.","solutions":["Inspect the constraint string in the error and correct its syntax to go-version format (e.g. '>= 1.0, < 2.0').","Re-download the hub index (cscli hub update) if the constraint came from hub metadata.","Update crowdsec if the constraint constant in your binary is outdated/incorrect.","For developers: validate constraints against goversion.NewConstraint in tests."],"exampleFix":"// before\nconstraint.Satisfies(v, \"1.0 - 2.0\")\n// after\nconstraint.Satisfies(v, \">= 1.0, < 2.0\")","handlingStrategy":"validation","validationCode":"if _, err := goversion.NewConstraint(constraintStr); err != nil {\n    return fmt.Errorf(\"constraint %q invalid: %w\", constraintStr, err)\n}","typeGuard":null,"tryCatchPattern":"ok, err := constraint.Satisfies(v, c)\nif err != nil {\n    return fmt.Errorf(\"constraint check failed: %w\", err)\n}\nif !ok { return ErrIncompatible }","preventionTips":["Write constraints in go-version syntax: '>= 1.0, < 2.0'","Re-fetch hub metadata if constraints come from the hub index","Unit-test any newly introduced constraint constant"],"tags":["go","versioning","constraint"],"backgroundTag":"invalid-argument-format","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}