{"record":{"id":"5e2a28b438a02871","repo":"hashicorp/packer","slug":"min-version-is-invalid-s","errorCode":null,"errorMessage":"min_version is invalid: %s","messagePattern":"min_version is invalid: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packer/core.go","lineNumber":870,"sourceCode":"// richer semantic checks around variables and so on.\nfunc (c *Core) validate() error {\n\t// First validate the template in general, we can't do anything else\n\t// unless the template itself is valid.\n\tif err := c.Template.Validate(); err != nil {\n\t\treturn err\n\t}\n\n\t// Validate the minimum version is satisfied\n\tif c.Template.MinVersion != \"\" {\n\t\tversionActual, err := version.NewVersion(c.version)\n\t\tif err != nil {\n\t\t\t// This shouldn't happen since we set it via the compiler\n\t\t\tpanic(err)\n\t\t}\n\n\t\tversionMin, err := version.NewVersion(c.Template.MinVersion)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\n\t\t\t\t\"min_version is invalid: %s\", err)\n\t\t}\n\n\t\tif versionActual.LessThan(versionMin) {\n\t\t\treturn fmt.Errorf(\n\t\t\t\t\"This template requires Packer version %s or higher; using %s\",\n\t\t\t\tversionMin,\n\t\t\t\tversionActual)\n\t\t}\n\t}\n\n\t// Validate variables are set\n\tvar err error\n\tfor n, v := range c.Template.Variables {\n\t\tif v.Required {\n\t\t\tif _, ok := c.variables[n]; !ok {\n\t\t\t\terr = multierror.Append(err, fmt.Errorf(\n\t\t\t\t\t\"required variable not set: %s\", n))","sourceCodeStart":852,"sourceCodeEnd":888,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/packer/core.go#L852-L888","documentation":"Thrown by Core.validate() at packer/core.go:870 when the template declares a `min_version` that HashiCorp go-version cannot parse. Packer validates the declared minimum required Packer version, and an unparseable string (not a valid semver-like version) fails before any comparison happens.","triggerScenarios":"Core.validate() (called from Core.initialize during GetBuilds) sees c.Template.MinVersion != \"\" and version.NewVersion(MinVersion) returns an error — the string is not a valid version like \"1.7.0\".","commonSituations":"Writing `min_version = \"v1.7.0\"` with a leading 'v' in contexts where it is unsupported; using ranges or comparators (\">= 1.7\") instead of a plain version; typos like \"1..7\" or \"latest\"; copying an HCL required_version constraint into the min_version field.","solutions":["Set min_version to a plain version string, e.g. `min_version = \"1.7.0\"`","Remove any leading 'v', comparators, ranges, or non-numeric suffixes from the value","Remove the min_version attribute entirely if version pinning is not needed"],"exampleFix":"// before\nmin_version = \">= 1.7.0\"\n// after\nmin_version = \"1.7.0\"","handlingStrategy":"validation","validationCode":"# ensure min_version parses before invoking packer\ngrep -oP 'min_version\\s*=\\s*\"\\K[^\"]+' *.pkr.hcl | grep -vP '^\\d+\\.\\d+\\.\\d+$' && echo 'invalid min_version found'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use plain x.y.z strings for min_version (no 'v', no comparators, no ranges)","Let CI run `packer validate` to catch malformed version constraints early","Distinguish required_version (supports constraints) from min_version (plain version) when writing templates"],"tags":["packer","version","template","validation"],"backgroundTag":"invalid-version-constraint","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}