{"record":{"id":"3c8e59f99189934e","repo":"wagoodman/dive","slug":"invalid-highestwastedbytes-config-value-given-q","errorCode":null,"errorMessage":"invalid highestWastedBytes config value, given %q: %v","messagePattern":"invalid highestWastedBytes config value, given %q: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/dive/cli/internal/command/ci/rules.go","lineNumber":136,"sourceCode":"\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}\n\treturn RulePassed, \"\"\n}\n\n// NewHighestWastedBytesRule creates a new rule to check wasted bytes\nfunc NewHighestWastedBytesRule(configValue string) (Rule, error) {\n\tif isRuleDisabled(configValue) {\n\t\treturn DisabledRule(ciKeyHighestWastedBytes), nil\n\t}\n\n\tthreshold, err := humanize.ParseBytes(configValue)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid highestWastedBytes config value, given %q: %v\",\n\t\t\tconfigValue, err)\n\t}\n\n\treturn &HighestWastedBytesRule{\n\t\tBaseRule: BaseRule{\n\t\t\tkey:         ciKeyHighestWastedBytes,\n\t\t\tconfigValue: configValue,\n\t\t},\n\t\tthreshold: threshold,\n\t}, nil\n}\n\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}","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/wagoodman/dive/blob/d6c691947f8fda635c952a17ee3b7555379d58f0/cmd/dive/cli/internal/command/ci/rules.go#L118-L154","documentation":"Returned when the highestWastedBytes CI rule value cannot be parsed by humanize.ParseBytes. Unlike the float rules, this one accepts human-readable byte strings — \"100MB\", \"1GiB\", \"1.5GB\", plain byte counts — and rejects anything not in that grammar (bare percentages, unknown unit suffixes, empty strings).","triggerScenarios":"highestWastedBytes: \"1GB\" parses; values like \"50%\", \"1 GB \" with unsupported formatting, \"ten megabytes\", or \"1TB2\" fail humanize.ParseBytes and surface this error at startup.","commonSituations":"Users assuming all rules take fractions and writing \"0.1\" expecting 10% (that parses as 0.1 bytes — nearly zero, a different bug); unit typos like \"1mb\" vs supported forms; config values pasted from other tools' formats.","solutions":["Use an explicit byte-size string with a binary/decimal unit: \"100MB\", \"1GiB\", \"5GB\"","Do not use percentages for this rule — it is an absolute byte count","Avoid bare small numbers: \"2\" means 2 bytes and will fail every real image","Check for stray characters/spaces around the value in the YAML"],"exampleFix":"# before\nrules:\n  highestWastedBytes: \"0.1\"   # meant 10% — actually 0.1 bytes\n\n# after\nrules:\n  highestWastedBytes: \"100MB\"","handlingStrategy":"validation","validationCode":"// pre-validate byte-size strings with the same parser the rule uses\nif _, err := humanize.ParseBytes(cfg.HighestWastedBytes); err != nil {\n    return fmt.Errorf(\"highestWastedBytes must look like '100MB' or '1GiB': %w\", err)\n}","typeGuard":"func isValidByteSize(s string) bool {\n    n, err := humanize.ParseBytes(s)\n    return err == nil && n > 0\n}","tryCatchPattern":"rule, err := ci.NewHighestWastedBytesRule(value)\nif err != nil && strings.Contains(err.Error(), \"invalid highestWastedBytes\") {\n    // guide the user: absolute byte size with unit, not a fraction/percent\n}\nif err != nil { return err }","preventionTips":["Always include a unit (MB/GiB) in highestWastedBytes","Remember this rule is absolute bytes, unlike the percent rules","Beware bare numbers — '2' means 2 bytes"],"tags":["ci","config","validation","bytes","humanize","rules"],"backgroundTag":null,"analyzedSha":"d6c691947f8fda635c952a17ee3b7555379d58f0","analyzedAt":"2026-08-15T09:42:35.293Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}