JuliusBrussee/caveman · error
cacheengine: nil engine
Error message
cacheengine: nil engine
What it means
Optimize was invoked on a nil or incompletely constructed Engine (nil receiver, or missing guard/prefix-safety/profile-resolver internals). Engines built by New are always complete; this guard catches zero-value or manually assembled structs.
Source
Thrown at cacheengine/native.go:20
import (
"bytes"
"context"
"encoding/json"
"errors"
"io"
"strconv"
"strings"
"time"
"github.com/JuliusBrussee/caveman/proxy/providers/jsonsplice"
)
// Optimize applies provider-native cache metadata or returns copied original
// bytes on every unsupported or unsafe path. It makes no network call.
func (e *Engine) Optimize(ctx context.Context, request NativeRequest) (NativeResult, error) {
if e == nil || e.guard == nil || e.prefixSafety == nil || e.resolveProfile == nil {
return NativeResult{}, errors.New("cacheengine: nil engine")
}
if e.configErr != nil {
return NativeResult{}, e.configErr
}
if ctx == nil {
return NativeResult{}, errors.New("cacheengine: nil context")
}
if err := ctx.Err(); err != nil {
return NativeResult{}, err
}
if len(request.Body) > e.maxRequestBytes {
return NativeResult{}, errors.New("cacheengine: request exceeds configured byte limit")
}
original := append([]byte(nil), request.Body...)
unsupported := Profile{ID: "unsupported", Mode: ModeUnsupported, Attribution: AttributionNone}
result := NativeResult{
Body: original,
Decision: DecisionPassThrough,View on GitHub (pinned to 766dce6b13)
Solutions
- Construct the engine via cacheengine.New/NewChecked before calling Optimize
- Check the engine pointer at call sites that may receive an optional engine
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cacheengine/native.go:20 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18).
Data as JSON: /api/errors/e11f83fe69362c04.
Report an issue: GitHub.