dagger/dagger · error
metadata prune: target estimated bytes must be positive and
Error message
metadata prune: target estimated bytes must be positive and lower than maximum
What it means
PruneMetadataEstimate requires 0 < targetBytes < maximumBytes: the target must be positive and strictly below the maximum so prune can shrink the cache to a level under the cap. Violating this invariant aborts the prune with this error.
Source
Thrown at dagql/cache_prune.go:127
started := time.Now()
report.MaximumEstimatedBytes = maximumBytes
report.TargetEstimatedBytes = targetBytes
defer func() {
report.Duration = time.Since(started)
if report.Triggered && c != nil {
c.traceMetadataPruneFinished(ctx, report, rerr)
metadataPruneLog(ctx, report, rerr)
}
}()
if c == nil {
return report, fmt.Errorf("metadata prune: nil cache")
}
if maximumBytes <= 0 {
return report, fmt.Errorf("metadata prune: maximum estimated bytes must be positive")
}
if targetBytes <= 0 || targetBytes >= maximumBytes {
return report, fmt.Errorf("metadata prune: target estimated bytes must be positive and lower than maximum")
}
if err := ctx.Err(); err != nil {
return report, err
}
c.egraphMu.Lock()
report.BeforeCompaction = c.cacheMetadataEstimateLocked()
report.AfterInitialCompaction = report.BeforeCompaction
report.AfterPrune = report.BeforeCompaction
if report.BeforeCompaction.EstimatedBytes <= maximumBytes {
c.egraphMu.Unlock()
return report, nil
}
report.Triggered = true
c.traceMetadataPruneStarted(ctx, maximumBytes, targetBytes)
_, report.InitialCompactionOldClassSlots, report.InitialCompactionNewClassSlots = c.compactEqClassesLocked(true)
report.AfterInitialCompaction = c.cacheMetadataEstimateLocked()
report.AfterPrune = report.AfterInitialCompactionView on GitHub (pinned to 82ba2681db)
Solutions
- Ensure targetBytes is strictly between 0 and maximumBytes
- Check argument order and derivation (e.g. target = max * 0.8)
- Add caller-side validation before invoking prune
Example fix
// before report, err := cache.PruneMetadataEstimate(ctx, max, max) // invalid // after target := max * 80 / 100 report, err := cache.PruneMetadataEstimate(ctx, max, target)
Defensive patterns
Strategy: validation
Validate before calling
if targetBytes <= 0 || targetBytes >= maxBytes {
return fmt.Errorf("targetBytes must be in (0, %d), got %d", maxBytes, targetBytes)
}
report, err := cache.PruneMetadataEstimate(ctx, maxBytes, targetBytes) Prevention
- Derive target as a fraction of max (e.g. 80%) rather than independent config
- Check argument order at every call site
- Add a config sanity check: 0 < target < max
When it happens
Trigger: Calling PruneMetadataEstimate with targetBytes <= 0, or targetBytes >= maximumBytes (equal values included) — e.g. miscomputed ratios (target==max), inverted arguments, or zero target from unset config.
Common situations: Configuration where target and max are set to the same value; passing arguments in the wrong order (target, max) swapped; target derived as a percentage that rounds to 0 or 100%.
Related errors
- metadata prune: maximum estimated bytes must be positive
- gc.dagqlCache.maxEstimatedBytes must be positive (resolved m
- gc.dagqlCache.targetEstimatedBytes must be positive and lowe
- unknown sdk config keys found %v
- key %q cannot be stored in user-level config; only modules.<
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/66688472f0df9c80.
Report an issue: GitHub.