{"record":{"id":"a36cdedebbe19adf","repo":"hashicorp/nomad","slug":"could-not-parse-value-as-bytes-v-a36cde","errorCode":null,"errorMessage":"could not parse value as bytes: %v","messagePattern":"could not parse value as bytes: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/volume_register_csi.go","lineNumber":194,"sourceCode":"\t}\n\n\treturn vol, nil\n}\n\nfunc parseCapacityBytes(cap *ast.ObjectList) (int64, error) {\n\tif len(cap.Items) > 0 {\n\t\tfor _, o := range cap.Elem().Items {\n\t\t\tlit, ok := o.Val.(*ast.LiteralType)\n\t\t\tif !ok {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tliteral := strings.Trim(lit.Token.Text, \"\\\"\")\n\t\t\tif literal == \"\" {\n\t\t\t\treturn 0, nil\n\t\t\t}\n\t\t\tb, err := humanize.ParseBytes(literal)\n\t\t\tif err != nil {\n\t\t\t\treturn 0, fmt.Errorf(\"could not parse value as bytes: %v\", err)\n\t\t\t}\n\t\t\treturn int64(b), err\n\t\t}\n\t}\n\treturn 0, nil\n}\n","sourceCodeStart":176,"sourceCodeEnd":201,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/volume_register_csi.go#L176-L201","documentation":"parseCapacityBytes walks the filtered HCL node looking for a string literal, trims quotes, and passes it to humanize.ParseBytes. Any non-empty literal that humanize cannot parse as a byte quantity produces `could not parse value as bytes: <reason>`. This is the underlying error wrapped by the invalid capacity_min / capacity_max messages.","triggerScenarios":"Any capacity value (capacity_min or capacity_max, also decodeHostVolume's capacity) that is a non-empty string not accepted by dustin/go-humanize.ParseBytes — e.g. \"10 TBs\", \"1,5 GB\", \"bogus\".","commonSituations":"Decimal commas instead of dots; invented units (\"TBs\", \"gigs\"); accidental whitespace/characters; forgetting that an empty string is the only 'unset' sentinel.","solutions":["Format the value with a humanize-compatible suffix: bytes, KB/MB/GB/TB (SI) or KiB/MiB/GiB/TiB (binary), e.g. \"5GiB\".","Use a plain integer to express raw bytes.","Use an empty string to represent zero/unset."],"exampleFix":"// before\ncapacity_min = \"1,5 GB\"\n// after\ncapacity_min = \"1.5GB\"","handlingStrategy":"validation","validationCode":"func parseCapacity(s string) (int64, error) {\n\tif s == \"\" { return 0, nil }\n\tb, err := humanize.ParseBytes(strings.Trim(s, \"\\\"\"))\n\treturn int64(b), err\n}\n// call before constructing the spec\nif _, err := parseCapacity(raw); err != nil { return err }","typeGuard":null,"tryCatchPattern":"b, err := parseCapacityBytes(list.Filter(\"capacity_min\"))\nif err != nil {\n\treturn fmt.Errorf(\"capacity must look like '10GiB' or '10000000000': %v\", err)\n}","preventionTips":["Use only units accepted by dustin/go-humanize: B, KB, MB, GB, TB, KiB, MiB, GiB, TiB.","Use dots, not commas, for decimals.","Treat empty string as the only 'unset' value."],"tags":["hcl","parsing","humanize","validation"],"backgroundTag":"invalid-capacity-value","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}