wagoodman/dive · error
invalid highestUserWastedPercent config value, given %q: %v
Error message
invalid highestUserWastedPercent config value, given %q: %v
What it means
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.
Source
Thrown at cmd/dive/cli/internal/command/ci/rules.go:166
func (r *HighestWastedBytesRule) Evaluate(analysis *image.Analysis) (RuleStatus, string) {
if analysis.WastedBytes > r.threshold {
return RuleFailed, fmt.Sprintf(
"too many bytes wasted (wasted-bytes=%d > threshold=%v)",
analysis.WastedBytes, r.threshold)
}
return RulePassed, ""
}
// NewHighestUserWastedPercentRule creates a new rule to check percentage of wasted bytes
func NewHighestUserWastedPercentRule(configValue string) (Rule, error) {
if isRuleDisabled(configValue) {
return DisabledRule(ciKeyHighestUserWastedPercent), nil
}
threshold, err := strconv.ParseFloat(configValue, 64)
if err != nil {
return nil, fmt.Errorf("invalid highestUserWastedPercent config value, given %q: %v",
configValue, err)
}
if threshold < 0 || threshold > 1 {
return nil, fmt.Errorf("highestUserWastedPercent config value is outside allowed range (0-1), given '%f'",
threshold)
}
return &HighestUserWastedPercentRule{
BaseRule: BaseRule{
key: ciKeyHighestUserWastedPercent,
configValue: configValue,
},
threshold: threshold,
}, nil
}
func (r *HighestUserWastedPercentRule) Evaluate(analysis *image.Analysis) (RuleStatus, string) {View on GitHub (pinned to d6c691947f)
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
Example fix
# before rules: highestUserWastedPercent: "40%" # after rules: highestUserWastedPercent: "0.4"
Defensive patterns
Strategy: validation
Validate before calling
if _, err := strconv.ParseFloat(cfg.HighestUserWastedPercent, 64); err != nil {
return fmt.Errorf("highestUserWastedPercent must be a decimal fraction like 0.4: %w", err)
} 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.NewHighestUserWastedPercentRule(value)
if err != nil && strings.Contains(err.Error(), "invalid highestUserWastedPercent") {
// config-format error: show expected form ("0.4" for 40%)
}
if err != nil { return err } Prevention
- 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
When it happens
Trigger: highestUserWastedPercent set to "0.4" works; "40%", "0,4", or a non-numeric placeholder string fails ParseFloat and raises this error before analysis begins.
Common situations: Teams writing whole-percent values from style guides; configs edited in locales with comma decimals; template variables left unfilled ("{{MAX_WASTED}}") reaching production.
Related errors
- invalid %s config value, given %q: %v
- %s config value is outside allowed range (0-1), given '%f'
- invalid highestWastedBytes config value, given %q: %v
- highestUserWastedPercent config value is outside allowed ran
- evaluation failed
AI-assisted analysis of wagoodman/dive@d6c691947f (2026-08-15).
Data as JSON: /api/errors/657005e1710a63e5.
Report an issue: GitHub.