{"record":{"id":"0906a5a1226cc4c6","repo":"dgraph-io/dgraph","slug":"error-s-must-be-less-than-s","errorCode":null,"errorMessage":"error: `%s` must be less than `%s`","messagePattern":"error: `(.+?)` must be less than `(.+?)`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upgrade/upgrade.go","lineNumber":196,"sourceCode":"\nfunc validateAndParseInput() (*commandInput, error) {\n\t_, _, err := net.SplitHostPort(strings.TrimSpace(Upgrade.Conf.GetString(alpha)))\n\tif err != nil {\n\t\treturn nil, formatAsFlagParsingError(alpha, err)\n\t}\n\n\tfromVersionParsed, err := parseVersionFromString(Upgrade.Conf.GetString(from))\n\tif err != nil {\n\t\treturn nil, formatAsFlagParsingError(from, err)\n\t}\n\n\ttoVersionParsed, err := parseVersionFromString(Upgrade.Conf.GetString(to))\n\tif err != nil {\n\t\treturn nil, formatAsFlagParsingError(to, err)\n\t}\n\n\tif fromVersionParsed.Compare(toVersionParsed) != less {\n\t\treturn nil, fmt.Errorf(\"error: `%s` must be less than `%s`\", from, to)\n\t}\n\n\treturn &commandInput{fromVersion: fromVersionParsed, toVersion: toVersionParsed}, nil\n}\n\nfunc formatAsFlagParsingError(flag string, err error) error {\n\treturn fmt.Errorf(\"error parsing flag `%s`: %w\", flag, err)\n}\n\n// parseVersionFromString parses a version given as string to internal representation.\n// Some examples for input and output:\n//  1. input : v1.2.2\n//     output: &version{major: 1, minor: 2, patch: 2}, nil\n//  2. input : v20.03.0-beta.20200320\n//     output: &version{major: 20, minor: 3, patch: 0}, nil\n//  3. input : 1.2.2\n//     output: nil, error\n//  4. input : v1.2.2s","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/upgrade/upgrade.go#L178-L214","documentation":"The dgraph upgrade command validates that the --from version is strictly less than the --to version by comparing parsed version structs. This error is returned from validateAndParseInput (via run) when from >= to, meaning the requested upgrade range is invalid or reversed.","triggerScenarios":"Running dgraph upgrade with --from greater than or equal to --to, e.g. --from v21.03.0 --to v20.11.0, or equal versions --from v21.03.0 --to v21.03.0.","commonSituations":"Typos in version flags, scripting mistakes where variables are swapped, attempting a downgrade (not supported by this command).","solutions":["Swap the flag values so the older version is --from and the newer version is --to.","Use valid semver values prefixed with v, e.g. dgraph upgrade offline -f v20.11.0 -t v21.03.0.","If you intended a downgrade, use the correct restore/backup workflow instead — this command only upgrades forward.","Check scripts for swapped variables in the flag invocation."],"exampleFix":"// before\ndgraph upgrade offline -f v21.03.0 -t v20.11.0\n// after\ndgraph upgrade offline -f v20.11.0 -t v21.03.0","handlingStrategy":"validation","validationCode":"func validUpgradeRange(from, to string) bool {\n\t// vMAJOR.MINOR.PATCH\n\tre := regexp.MustCompile(`^v\\d+\\.\\d+\\.\\d+$`)\n\tif !re.MatchString(from) || !re.MatchString(to) { return false }\n\tcmp := func(v string) int {\n\t\tp := strings.Split(strings.TrimPrefix(v, \"v\"), \".\")\n\t\ta, _ := strconv.Atoi(p[0]); b, _ := strconv.Atoi(p[1]); c, _ := strconv.Atoi(p[2])\n\t\treturn a*10000 + b*100 + c\n\t}\n\treturn cmp(from) < cmp(to)\n}\n// use: if !validUpgradeRange(fromVer, toVer) { fix flags before running }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass the older version to --from and the newer to --to","Never attempt downgrades with dgraph upgrade","Script flag order carefully; use named flags to avoid swaps","Echo both versions before invoking the command"],"tags":["cli","versioning","validation"],"backgroundTag":"invalid-version-range","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}