{"record":{"id":"ecaa8c9cfa965fcf","repo":"dagger/dagger","slug":"error-converting-value-to-int64-w","errorCode":null,"errorMessage":"error converting value to int64: %w","messagePattern":"error converting value to int64: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"engine/engineutil/resources/memorystat.go","lineNumber":56,"sourceCode":"\t\tmemoryCurrentFilePath: filepath.Join(cgroupPath, memoryCurrentFile),\n\t\tcommonAttrs:           commonAttrs,\n\t\tmemoryCurrent:         memoryCurrent,\n\t}, nil\n}\n\nfunc (s *memoryCurrentSampler) sample(ctx context.Context) error {\n\tsample := newInt64GaugeSample(s.memoryCurrent, s.commonAttrs)\n\tbs, err := os.ReadFile(s.memoryCurrentFilePath)\n\tswitch {\n\tcase errors.Is(err, os.ErrNotExist):\n\t\treturn nil\n\tcase err != nil:\n\t\treturn fmt.Errorf(\"failed to read %s: %w\", s.memoryCurrentFilePath, err)\n\t}\n\n\tvalue, err := singleValue(bs)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error converting value to int64: %w\", err)\n\t}\n\n\tsample.add(value)\n\tsample.record(ctx)\n\n\treturn nil\n}\n\ntype memoryPeakSampler struct {\n\tmemoryPeakFilePath string\n\tcommonAttrs        attribute.Set\n\n\tmemoryPeak metric.Int64Gauge\n}\n\nfunc newMemoryPeakSampler(cgroupPath string, meter metric.Meter, commonAttrs attribute.Set) (*memoryPeakSampler, error) {\n\tmemoryPeak, err := meter.Int64Gauge(\n\t\ttelemetry.MemoryPeakBytes,","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/engine/engineutil/resources/memorystat.go#L38-L74","documentation":"After successfully reading memory.current, singleValue(bs) failed to parse/convert the file contents into an int64, so sample() wraps the parse error. This means the cgroup file existed and was readable but did not contain a single parseable integer value.","triggerScenarios":"Sampler tick calls memoryCurrentSampler.sample(); the bytes read from memory.current are empty, contain unexpected text (e.g. masked/synthetic file from a sandboxed runtime), or singleValue's strconv.ParseInt fails.","commonSituations":"Reading a mocked or stub cgroup filesystem (unit tests, gVisor/user-space shims) that emits non-numeric content; truncated read returning empty bytes; cgroup file format change or vendor patching.","solutions":["Inspect the wrapped parse error and dump the raw file bytes to see what memory.current actually contained.","Verify the container runtime exposes a real kernel cgroup v2 memory.current (a single integer); fix the runtime/shim if it emits other content.","Harden singleValue to skip whitespace/BOM and give a clearer error including the offending content.","Skip the tick (return nil with a warning) on parse failure so telemetry collection continues."],"exampleFix":"// before\nvalue, err := singleValue(bs)\nif err != nil { return fmt.Errorf(\"error converting value to int64: %w\", err) }\n// after\nvalue, err := singleValue(bytes.TrimSpace(bs))\nif err != nil {\n    log.Warn(\"unparseable memory.current; skipping\", \"content\", string(bs), \"err\", err)\n    return nil\n}","handlingStrategy":"validation","validationCode":"bs, err := os.ReadFile(filepath.Join(cgroupPath, \"memory.current\"))\nif err == nil {\n    if _, perr := strconv.ParseInt(strings.TrimSpace(string(bs)), 10, 64); perr != nil { log.Warn(\"memory.current not an integer\", \"content\", string(bs)) }\n}","typeGuard":"func isParseable(bs []byte) bool {\n    _, err := strconv.ParseInt(strings.TrimSpace(string(bs)), 10, 64)\n    return err == nil\n}","tryCatchPattern":"if err := sampler.Sample(ctx); err != nil {\n    if strings.Contains(err.Error(), \"converting value to int64\") { log.Warn(\"unparseable cgroup file; skipping tick\", \"err\", err) }\n}","preventionTips":["Trim whitespace before parsing cgroup values.","Verify the runtime emits numeric cgroup contents.","Log raw file content when parsing fails.","Skip unparseable ticks instead of failing collection."],"tags":["cgroup","parsing","linux","memory","telemetry"],"backgroundTag":"cgroup-file-parse-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}