{"record":{"id":"0917ad7f2a75baa6","repo":"wagoodman/dive","slug":"s-config-value-is-outside-allowed-range-0-1-gi","errorCode":null,"errorMessage":"%s config value is outside allowed range (0-1), given '%f'","messagePattern":"(.+?) config value is outside allowed range \\(0-1\\), given '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/dive/cli/internal/command/ci/rules.go","lineNumber":106,"sourceCode":"// HighestUserWastedPercentRule checks if percentage of wasted bytes is below threshold\ntype HighestUserWastedPercentRule struct {\n\tBaseRule\n\tthreshold float64\n}\n\nfunc NewLowestEfficiencyRule(configValue string) (Rule, error) {\n\tif isRuleDisabled(configValue) {\n\t\treturn DisabledRule(ciKeyLowestEfficiencyThreshold), nil\n\t}\n\n\tthreshold, err := strconv.ParseFloat(configValue, 64)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid %s config value, given %q: %v\",\n\t\t\tciKeyLowestEfficiencyThreshold, configValue, err)\n\t}\n\n\tif threshold < 0 || threshold > 1 {\n\t\treturn nil, fmt.Errorf(\"%s config value is outside allowed range (0-1), given '%f'\",\n\t\t\tciKeyLowestEfficiencyThreshold, threshold)\n\t}\n\n\treturn &LowestEfficiencyRule{\n\t\tBaseRule: BaseRule{\n\t\t\tkey:         ciKeyLowestEfficiencyThreshold,\n\t\t\tconfigValue: configValue,\n\t\t},\n\t\tthreshold: threshold,\n\t}, nil\n}\n\nfunc (r *LowestEfficiencyRule) Evaluate(analysis *image.Analysis) (RuleStatus, string) {\n\tif r.threshold > analysis.Efficiency {\n\t\treturn RuleFailed, fmt.Sprintf(\n\t\t\t\"image efficiency is too low (efficiency=%2.2f < threshold=%v)\",\n\t\t\tanalysis.Efficiency, r.threshold)\n\t}","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/wagoodman/dive/blob/d6c691947f8fda635c952a17ee3b7555379d58f0/cmd/dive/cli/internal/command/ci/rules.go#L88-L124","documentation":"Returned when lowestEfficiencyThreshold parses as a float but falls outside [0, 1]. The rule stores efficiency as a fraction (bytes-used / bytes-total), so 0 means 0% efficiency and 1 means 100%; values like 90 (intended as percent) or negatives are rejected immediately.","triggerScenarios":"lowestEfficiencyThreshold: \"0.95\" passes; \"95\" (percent-style), \"1.5\", or \"-0.1\" fail the 0–1 range check after successful ParseFloat.","commonSituations":"Migrating from tools that express thresholds in whole percentages; quick edits that drop the leading '0.'; intentionally passing >1 to 'disable' the rule instead of using the disabled sentinel.","solutions":["Express the threshold as a fraction: 95% efficiency becomes 0.95","Double-check decimals for typos (1.1 instead of 0.1)","Use the disabled sentinel value if you want the rule off rather than an impossible threshold","Remember edge semantics: 0 disables effectively, 1 demands a perfectly efficient image"],"exampleFix":"# before\nrules:\n  lowestEfficiencyThreshold: \"95\"\n\n# after\nrules:\n  lowestEfficiencyThreshold: \"0.95\"","handlingStrategy":"validation","validationCode":"f, err := strconv.ParseFloat(cfg.LowestEfficiencyThreshold, 64)\nif err == nil && (f < 0 || f > 1) {\n    return fmt.Errorf(\"lowestEfficiencyThreshold %f outside [0,1]; did you mean %f?\", f, f/100)\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.NewLowestEfficiencyRule(value)\nif err != nil && strings.Contains(err.Error(), \"outside allowed range\") {\n    // suggest the percent->fraction conversion in the error shown to users\n}\nif err != nil { return err }","preventionTips":["Document thresholds as fractions everywhere the config is edited","Reject out-of-range values in config linting before dive sees them","Prefer the disabled sentinel over impossible thresholds"],"tags":["ci","config","validation","range","rules"],"backgroundTag":null,"analyzedSha":"d6c691947f8fda635c952a17ee3b7555379d58f0","analyzedAt":"2026-08-15T09:42:35.293Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}