{"record":{"id":"f30c9bf60fb75e39","repo":"pulumi/pulumi","slug":"parsing-cli-version-q-w-f30c9b","errorCode":null,"errorMessage":"parsing CLI version %q: %w","messagePattern":"parsing CLI version %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/go/common/resource/plugin/plugin.go","lineNumber":711,"sourceCode":"\t}, nil\n}\n\n// ValidatePulumiVersionRange validates that the CLI version satisfies the passed version range. The supported syntax\n// for ranges is that of https://pkg.go.dev/github.com/blang/semver#ParseRange. For example \">=3.0.0\", or \"!3.1.2\".\n// Ranges can be AND-ed together by concatenating with spaces \">=3.5.0 !3.7.7\", meaning greater-or-equal to 3.5.0 and\n// not exactly 3.7.7. Ranges can be OR-ed with the `||` operator: \"<3.4.0 || >3.8.0\", meaning less-than 3.4.0 or\n// greater-than 3.8.0.\nfunc ValidatePulumiVersionRange(pulumiVersionRange, cliVersion string) error {\n\t// The cliVersion is the build version and will usually be set when running the Pulumi CLI, however it may be empty\n\t// when running non-integration tests.\n\tif pulumiVersionRange != \"\" && cliVersion != \"\" {\n\t\trg, err := semver.ParseRange(pulumiVersionRange)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"parsing CLI version range %q: %w\", pulumiVersionRange, err)\n\t\t}\n\t\tcliVersion, err := semver.ParseTolerant(cliVersion)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"parsing CLI version %q: %w\", version.Version, err)\n\t\t}\n\t\tif !rg(cliVersion) {\n\t\t\treturn fmt.Errorf(\n\t\t\t\t\"Pulumi CLI version %s does not satisfy the version range %q\", cliVersion, pulumiVersionRange)\n\t\t}\n\t}\n\treturn nil\n}\n\ntype pluginArgumentOptions struct {\n\tpluginArgs           []string\n\ttracingEndpoint      string\n\tlogFlow, logToStderr bool\n\tverbose              int\n}\n\nfunc buildPluginArguments(opts pluginArgumentOptions) []string {\n\tvar args []string","sourceCodeStart":693,"sourceCodeEnd":729,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/go/common/resource/plugin/plugin.go#L693-L729","documentation":"ValidatePulumiVersionRange throws this when the running Pulumi CLI's own version string cannot be parsed by semver.ParseTolerant. Note the message quotes the parsed parameter but formats version.Version (the build-time version), which may be empty or non-semver in custom builds.","triggerScenarios":"A plugin declares a pulumiVersionRange and cliVersion is non-empty, but semver.ParseTolerant(cliVersion) fails — typically when the CLI was built without proper version ldflags (version like 'dev' or empty) or a corrupted version string.","commonSituations":"Running a locally built pulumi binary without --ldflags version injection; a nightly/custom build whose version is not semver-shaped; mismatched version metadata.","solutions":["Install an official Pulumi CLI release via the standard installer or package manager","If building locally, set the version ldflags (e.g. make build with version variables) so version.Version is valid semver","Check `pulumi version` output; if it is not a valid semver string, reinstall"],"exampleFix":"// before (local build)\ngo build -o pulumi ./cmd/pulumi\n// after\ngo build -ldflags \"-X github.com/pulumi/pulumi/pkg/v3/version.Version=v3.100.0\" -o pulumi ./cmd/pulumi","handlingStrategy":"validation","validationCode":"// Ensure the CLI version is semver-parseable before enforcing ranges\nif _, err := semver.ParseTolerant(version.Version); err != nil {\n\treturn fmt.Errorf(\"CLI build lacks valid version metadata: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := ValidatePulumiVersionRange(rangeStr, cliVer); err != nil {\n\tif strings.Contains(err.Error(), \"parsing CLI version\") {\n\t\t// switch to an official CLI build\n\t}\n\treturn err\n}","preventionTips":["Use official pulumi releases rather than ad-hoc `go build`","When building locally, inject version via ldflags","Verify `pulumi version` prints a valid semver"],"tags":["go","semver","version-constraint"],"backgroundTag":"invalid-cli-version","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}