{"record":{"id":"48b46facaeaa6f83","repo":"apache/beam","slug":"resource-parsecpucount-unable-to-parse-q-v","errorCode":null,"errorMessage":"resource.ParseCPUCount: unable to parse %q: %v","messagePattern":"resource\\.ParseCPUCount: unable to parse %q: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/options/resource/hint.go","lineNumber":259,"sourceCode":"func (h acceleratorHint) MergeWithOuter(outer Hint) Hint {\n\treturn h\n}\n\nfunc (h acceleratorHint) String() string {\n\treturn fmt.Sprintf(\"accelerator=%v\", h.value)\n}\n\n// ParseCPUCount converts a number in string form into a hint.\n// An invalid format will cause ParseCPUCount to panic.\n//\n// Hints are advisory only and runners may not respect them.\n//\n// See https://beam.apache.org/documentation/runtime/resource-hints/ for more information about\n// resource hints.\nfunc ParseCPUCount(v string) Hint {\n\tb, err := strconv.ParseUint(v, 10, 64)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"resource.ParseCPUCount: unable to parse %q: %v\", v, err))\n\t}\n\treturn CPUCount(uint64(b))\n}\n\n// CPUCount hints that this scope should be put in a machine with at least this many CPUs or vCPUs.\n//\n// Hints are advisory only and runners may not respect them.\n//\n// See https://beam.apache.org/documentation/runtime/resource-hints/ for more information about\n// resource hints.\nfunc CPUCount(v uint64) Hint {\n\treturn CPUCountHint{value: uint64(v)}\n}\n\ntype CPUCountHint struct {\n\tvalue uint64\n}\n","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/options/resource/hint.go#L241-L277","documentation":"ParseCPUCount converts a string to an unsigned 64-bit CPU count via strconv.ParseUint(v, 10, 64). If the value is not a valid non-negative integer it panics with 'resource.ParseCPUCount: unable to parse %q: %v'.","triggerScenarios":"Calling resource.ParseCPUCount with a non-integer, negative number ('-2'), or out-of-range value, or feeding such a value through --resource_hints=cpu_count=<bad>.","commonSituations":"Passing '4 cores', a negative value, or an empty string from an unset flag/env var into the hint.","solutions":["Supply a plain non-negative decimal integer string, e.g. '4'","Trim whitespace and remove unit suffixes like 'cores' or 'vCPU'","Guard with strconv.ParseUint in the caller before constructing the hint"],"exampleFix":"// before\nresource.ParseCPUCount(\"-2\")\n// after\nresource.ParseCPUCount(\"4\")","handlingStrategy":"validation","validationCode":"if n, err := strconv.ParseUint(v, 10, 64); err != nil {\n    return fmt.Errorf(\"invalid cpu count %q\", v)\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        err = fmt.Errorf(\"ParseCPUCount rejected value: %v\", r)\n    }\n}()","preventionTips":["Pass non-negative decimal integer strings only","Remove unit suffixes like 'cores'/'vCPU' before parsing","Handle unset config by substituting a default before calling ParseCPUCount"],"tags":["go","beam","resource-hints","parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}