wagoodman/dive · error
%s config value is outside allowed range (0-1), given '%f'
Error message
%s config value is outside allowed range (0-1), given '%f'
What it means
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.
Source
Thrown at cmd/dive/cli/internal/command/ci/rules.go:106
// HighestUserWastedPercentRule checks if percentage of wasted bytes is below threshold
type HighestUserWastedPercentRule struct {
BaseRule
threshold float64
}
func NewLowestEfficiencyRule(configValue string) (Rule, error) {
if isRuleDisabled(configValue) {
return DisabledRule(ciKeyLowestEfficiencyThreshold), nil
}
threshold, err := strconv.ParseFloat(configValue, 64)
if err != nil {
return nil, fmt.Errorf("invalid %s config value, given %q: %v",
ciKeyLowestEfficiencyThreshold, configValue, err)
}
if threshold < 0 || threshold > 1 {
return nil, fmt.Errorf("%s config value is outside allowed range (0-1), given '%f'",
ciKeyLowestEfficiencyThreshold, threshold)
}
return &LowestEfficiencyRule{
BaseRule: BaseRule{
key: ciKeyLowestEfficiencyThreshold,
configValue: configValue,
},
threshold: threshold,
}, nil
}
func (r *LowestEfficiencyRule) Evaluate(analysis *image.Analysis) (RuleStatus, string) {
if r.threshold > analysis.Efficiency {
return RuleFailed, fmt.Sprintf(
"image efficiency is too low (efficiency=%2.2f < threshold=%v)",
analysis.Efficiency, r.threshold)
}View on GitHub (pinned to d6c691947f)
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
Example fix
# before rules: lowestEfficiencyThreshold: "95" # after rules: lowestEfficiencyThreshold: "0.95"
Defensive patterns
Strategy: validation
Validate before calling
f, err := strconv.ParseFloat(cfg.LowestEfficiencyThreshold, 64)
if err == nil && (f < 0 || f > 1) {
return fmt.Errorf("lowestEfficiencyThreshold %f outside [0,1]; did you mean %f?", f, f/100)
} Type guard
func isValidFraction(s string) bool {
f, err := strconv.ParseFloat(s, 64)
return err == nil && f >= 0 && f <= 1
} Try / catch
rule, err := ci.NewLowestEfficiencyRule(value)
if err != nil && strings.Contains(err.Error(), "outside allowed range") {
// suggest the percent->fraction conversion in the error shown to users
}
if err != nil { return err } Prevention
- 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
When it happens
Trigger: lowestEfficiencyThreshold: "0.95" passes; "95" (percent-style), "1.5", or "-0.1" fail the 0–1 range check after successful ParseFloat.
Common situations: 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.
Related errors
- highestUserWastedPercent config value is outside allowed ran
- invalid %s config value, given %q: %v
- invalid highestWastedBytes config value, given %q: %v
- invalid highestUserWastedPercent config value, given %q: %v
- evaluation failed
AI-assisted analysis of wagoodman/dive@d6c691947f (2026-08-15).
Data as JSON: /api/errors/0917ad7f2a75baa6.
Report an issue: GitHub.