{"record":{"id":"a05ff97fd0a97148","repo":"charmbracelet/gum","slug":"could-not-parse-range-s-w","errorCode":null,"errorMessage":"could not parse range %s: %w","messagePattern":"could not parse range (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"version/command.go","lineNumber":15,"sourceCode":"// Package version the version command.\npackage version\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/Masterminds/semver/v3\"\n\t\"github.com/alecthomas/kong\"\n)\n\n// Run check that a given version matches a semantic version constraint.\nfunc (o Options) Run(ctx *kong.Context) error {\n\tc, err := semver.NewConstraint(o.Constraint)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not parse range %s: %w\", o.Constraint, err)\n\t}\n\tcurrent := ctx.Model.Vars()[\"versionNumber\"]\n\tv, err := semver.NewVersion(current)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not parse version %s: %w\", current, err)\n\t}\n\tif !c.Check(v) {\n\t\treturn fmt.Errorf(\"gum version %q is not within given range %q\", current, o.Constraint)\n\t}\n\treturn nil\n}\n","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/charmbracelet/gum/blob/4d089f95507708a71f64dacfe7ca513219dd5267/version/command.go#L1-L27","documentation":"`gum version --check` could not parse the provided --constraint string as a valid semantic version constraint (Masterminds/semver). The constraint must be an expression like '>= 1.2.0' or '~1.0'. The parse error is wrapped with %w.","triggerScenarios":"Running `gum version --check` with a constraint string semver.NewConstraint rejects — typos, empty string, or unsupported syntax like 'v1.x' wildcards or bare ranges.","commonSituations":"Typing 'greater than 1.0' instead of '>= 1.0.0', passing shell-unescaped '>' that the shell mangles, empty constraint variable in a script, using prerelease notation incorrectly.","solutions":["Use valid semver constraint syntax, e.g. --check '>= 0.14.0'","Quote the constraint in the shell so '>' isn't interpreted as redirection","Verify the constraint variable is non-empty in scripts","Check Masterminds/semver docs for supported constraint operators"],"exampleFix":"// before\ngum version --check > 1.0.0     # shell treats '>' as redirect\n// after\ngum version --check \">= 1.0.0\"","handlingStrategy":"validation","validationCode":"constraint='>= 0.14.0'\n[[ \"$constraint\" =~ ^[><=~![:space:]]*[0-9]+\\.[0-9]+\\.[0-9]+$ ]] || { echo \"bad constraint: $constraint\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":"if ! gum version --check \"$constraint\" 2>err.txt; then\n  grep -q 'could not parse range' err.txt && echo 'fix constraint syntax' >&2\nfi","preventionTips":["Always quote constraints in shell to protect > and <","Use documented semver operators (>=, <=, ~, ^, =)","Validate constraint variables are non-empty before use"],"tags":["semver","cli","parsing"],"backgroundTag":"invalid-version-constraint","analyzedSha":"4d089f95507708a71f64dacfe7ca513219dd5267","analyzedAt":"2026-08-31T18:45:06.436Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}