{"record":{"id":"4869fe7652854d12","repo":"derailed/k9s","slug":"could-not-convert-revision-to-a-number-w","errorCode":null,"errorMessage":"could not convert revision to a number: %w","messagePattern":"could not convert revision to a number: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/dao/helm_history.go","lineNumber":147,"sourceCode":"\tif allValues {\n\t\tcontent = resp.Release.Chart.Values\n\t} else {\n\t\tcontent = resp.Release.Config\n\t}\n\n\treturn data.WriteYAML(content)\n}\n\nfunc (h *HelmHistory) Rollback(_ context.Context, path, rev string) error {\n\tns, n := client.Namespaced(path)\n\tcfg, err := ensureHelmConfig(h.Client().Config().Flags(), ns)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tver, err := strconv.Atoi(rev)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not convert revision to a number: %w\", err)\n\t}\n\tclt := action.NewRollback(cfg)\n\tclt.Version = ver\n\n\treturn clt.Run(n)\n}\n\n// Delete uninstall a Helm.\nfunc (h *HelmHistory) Delete(_ context.Context, path string, _ *metav1.DeletionPropagation, _ Grace) error {\n\tns, n := client.Namespaced(path)\n\tcfg, err := ensureHelmConfig(h.Client().Config().Flags(), ns)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tres, err := action.NewUninstall(cfg).Run(n)\n\tif err != nil {\n\t\treturn err","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/derailed/k9s/blob/2d3ccc6ba2ce98c3781bfc441bb3e884f072774f/internal/dao/helm_history.go#L129-L165","documentation":"Thrown by HelmHistory.Rollback when strconv.Atoi fails on the revision argument. The DAO maps the string revision (as printed by helm history) onto action.Rollback.Version, which is an int, so any non-decimal value cannot be converted. The %w wraps the strconv error, which names the offending input.","triggerScenarios":"Calling HelmHistory.Rollback(ctx, path, rev) with rev that is not a base-10 integer: empty string, \"latest\", \"1.2\", a release name, or a value with surrounding whitespace passed straight from a UI prompt.","commonSituations":"User types the revision by hand in the k9s helm rollback prompt and leaves it blank or enters the release name; callers forwarding a git SHA/tag instead of the numeric REVISION column; UI fields handed to the DAO unvalidated.","solutions":["Pass a plain integer string exactly as shown in the REVISION column of helm history (e.g. \"3\")","Validate with strconv.Atoi in the caller/UI before invoking Rollback and reject bad input early","Default the prompt to the previous revision fetched from HelmHistory.Table when the field is empty"],"exampleFix":"// before\nerr := h.Rollback(ctx, path, rev) // rev may be \"\" or \"latest\"\n\n// after\nrev = strings.TrimSpace(rev)\nif _, err := strconv.Atoi(rev); err != nil {\n    return fmt.Errorf(\"invalid revision %q: use a number from helm history\", rev)\n}\nerr := h.Rollback(ctx, path, rev)","handlingStrategy":"validation","validationCode":"rev = strings.TrimSpace(rev)\nif _, err := strconv.Atoi(rev); err != nil {\n    // reject before calling Rollback\n    return fmt.Errorf(\"revision %q is not a number (see helm history)\", rev)\n}","typeGuard":"func isValidRevision(rev string) bool {\n    _, err := strconv.Atoi(strings.TrimSpace(rev))\n    return err == nil\n}","tryCatchPattern":"if err := h.Rollback(ctx, path, rev); err != nil {\n    if strings.Contains(err.Error(), \"could not convert revision\") {\n        // bad input: surface to user, do not retry\n    }\n}","preventionTips":["Populate revision pickers from HelmHistory.Table instead of free-text input","Trim and Atoi-validate any user-supplied revision before it reaches the DAO","Remember strconv.Atoi rejects \"1.0\", \"+1\" is accepted but \"1_0\" is not — normalize first"],"tags":["helm","rollback","validation","strconv"],"backgroundTag":null,"analyzedSha":"2d3ccc6ba2ce98c3781bfc441bb3e884f072774f","analyzedAt":"2026-08-15T16:09:14.432Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}