{"record":{"id":"f62905d02b01eaef","repo":"crowdsecurity/crowdsec","slug":"failed-to-parse-s-w-f62905","errorCode":null,"errorMessage":"failed to parse '%s': %w","messagePattern":"failed to parse '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cwversion/constraint/constraint.go","lineNumber":19,"sourceCode":"package constraint\n\nimport (\n\t\"fmt\"\n\n\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":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/cwversion/constraint/constraint.go#L1-L33","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (bad file content)\nversion: latest\n// after\nversion: 1.0","handlingStrategy":"validation","validationCode":"if _, err := goversion.NewVersion(versionStr); err != nil {\n    return fmt.Errorf(\"item version %q is not a valid version: %w\", versionStr, err)\n}","typeGuard":null,"tryCatchPattern":"ok, err := constraint.Satisfies(vers, c)\nif err != nil {\n    log.Errorf(\"skipping item: %v\", err)\n    // fall back to treating item as compatible or skip it\n}","preventionTips":["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"],"tags":["go","versioning","config"],"backgroundTag":"schema-validation-failed","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"}