{"record":{"id":"657005e1710a63e5","repo":"wagoodman/dive","slug":"invalid-highestuserwastedpercent-config-value-giv","errorCode":null,"errorMessage":"invalid highestUserWastedPercent config value, given %q: %v","messagePattern":"invalid highestUserWastedPercent config value, given %q: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/dive/cli/internal/command/ci/rules.go","lineNumber":166,"sourceCode":"\nfunc (r *HighestWastedBytesRule) Evaluate(analysis *image.Analysis) (RuleStatus, string) {\n\tif analysis.WastedBytes > r.threshold {\n\t\treturn RuleFailed, fmt.Sprintf(\n\t\t\t\"too many bytes wasted (wasted-bytes=%d > threshold=%v)\",\n\t\t\tanalysis.WastedBytes, r.threshold)\n\t}\n\treturn RulePassed, \"\"\n}\n\n// NewHighestUserWastedPercentRule creates a new rule to check percentage of wasted bytes\nfunc NewHighestUserWastedPercentRule(configValue string) (Rule, error) {\n\tif isRuleDisabled(configValue) {\n\t\treturn DisabledRule(ciKeyHighestUserWastedPercent), nil\n\t}\n\n\tthreshold, err := strconv.ParseFloat(configValue, 64)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid highestUserWastedPercent config value, given %q: %v\",\n\t\t\tconfigValue, err)\n\t}\n\n\tif threshold < 0 || threshold > 1 {\n\t\treturn nil, fmt.Errorf(\"highestUserWastedPercent config value is outside allowed range (0-1), given '%f'\",\n\t\t\tthreshold)\n\t}\n\n\treturn &HighestUserWastedPercentRule{\n\t\tBaseRule: BaseRule{\n\t\t\tkey:         ciKeyHighestUserWastedPercent,\n\t\t\tconfigValue: configValue,\n\t\t},\n\t\tthreshold: threshold,\n\t}, nil\n}\n\nfunc (r *HighestUserWastedPercentRule) Evaluate(analysis *image.Analysis) (RuleStatus, string) {","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/wagoodman/dive/blob/d6c691947f8fda635c952a17ee3b7555379d58f0/cmd/dive/cli/internal/command/ci/rules.go#L148-L184","documentation":"Returned when the highestUserWastedPercent rule value fails strconv.ParseFloat. This rule bounds the fraction of wasted bytes attributable to user-added (non-reference) layers, and like the efficiency rule it must be a plain float string; percent notation and comma decimals are rejected at config-load time.","triggerScenarios":"highestUserWastedPercent set to \"0.4\" works; \"40%\", \"0,4\", or a non-numeric placeholder string fails ParseFloat and raises this error before analysis begins.","commonSituations":"Teams writing whole-percent values from style guides; configs edited in locales with comma decimals; template variables left unfilled (\"{{MAX_WASTED}}\") reaching production.","solutions":["Write the value as a fraction between 0 and 1, e.g. \"0.4\" for 40%","Strip %, commas, and template placeholders from the config value","Validate CI config files in a lint step (dive with a dummy image) before merging","Use the disabled sentinel if this rule should not apply"],"exampleFix":"# before\nrules:\n  highestUserWastedPercent: \"40%\"\n\n# after\nrules:\n  highestUserWastedPercent: \"0.4\"","handlingStrategy":"validation","validationCode":"if _, err := strconv.ParseFloat(cfg.HighestUserWastedPercent, 64); err != nil {\n    return fmt.Errorf(\"highestUserWastedPercent must be a decimal fraction like 0.4: %w\", err)\n}","typeGuard":"func isValidFraction(s string) bool {\n    f, err := strconv.ParseFloat(s, 64)\n    return err == nil && f >= 0 && f <= 1\n}","tryCatchPattern":"rule, err := ci.NewHighestUserWastedPercentRule(value)\nif err != nil && strings.Contains(err.Error(), \"invalid highestUserWastedPercent\") {\n    // config-format error: show expected form (\"0.4\" for 40%)\n}\nif err != nil { return err }","preventionTips":["Never write %, commas, or placeholders in threshold values","Render template configs fully before deploying","Lint all three CI rule values in one pre-flight step"],"tags":["ci","config","validation","parsing","rules"],"backgroundTag":null,"analyzedSha":"d6c691947f8fda635c952a17ee3b7555379d58f0","analyzedAt":"2026-08-15T09:42:35.293Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}