dagger/dagger · warning
error converting value to int64: %w
Error message
error converting value to int64: %w
What it means
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.
Source
Thrown at engine/engineutil/resources/memorystat.go:56
memoryCurrentFilePath: filepath.Join(cgroupPath, memoryCurrentFile),
commonAttrs: commonAttrs,
memoryCurrent: memoryCurrent,
}, nil
}
func (s *memoryCurrentSampler) sample(ctx context.Context) error {
sample := newInt64GaugeSample(s.memoryCurrent, s.commonAttrs)
bs, err := os.ReadFile(s.memoryCurrentFilePath)
switch {
case errors.Is(err, os.ErrNotExist):
return nil
case err != nil:
return fmt.Errorf("failed to read %s: %w", s.memoryCurrentFilePath, err)
}
value, err := singleValue(bs)
if err != nil {
return fmt.Errorf("error converting value to int64: %w", err)
}
sample.add(value)
sample.record(ctx)
return nil
}
type memoryPeakSampler struct {
memoryPeakFilePath string
commonAttrs attribute.Set
memoryPeak metric.Int64Gauge
}
func newMemoryPeakSampler(cgroupPath string, meter metric.Meter, commonAttrs attribute.Set) (*memoryPeakSampler, error) {
memoryPeak, err := meter.Int64Gauge(
telemetry.MemoryPeakBytes,View on GitHub (pinned to 82ba2681db)
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.
Example fix
// before
value, err := singleValue(bs)
if err != nil { return fmt.Errorf("error converting value to int64: %w", err) }
// after
value, err := singleValue(bytes.TrimSpace(bs))
if err != nil {
log.Warn("unparseable memory.current; skipping", "content", string(bs), "err", err)
return nil
} Defensive patterns
Strategy: validation
Validate before calling
bs, err := os.ReadFile(filepath.Join(cgroupPath, "memory.current"))
if err == nil {
if _, perr := strconv.ParseInt(strings.TrimSpace(string(bs)), 10, 64); perr != nil { log.Warn("memory.current not an integer", "content", string(bs)) }
} Type guard
func isParseable(bs []byte) bool {
_, err := strconv.ParseInt(strings.TrimSpace(string(bs)), 10, 64)
return err == nil
} Try / catch
if err := sampler.Sample(ctx); err != nil {
if strings.Contains(err.Error(), "converting value to int64") { log.Warn("unparseable cgroup file; skipping tick", "err", err) }
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- failed to read %s: %w
- failed to read %s: %w
- failed to read %s: %w
- create cgroup sampler: %w
- failed to create ioPressure sampler: %w
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/ecaa8c9cfa965fcf.
Report an issue: GitHub.