JuliusBrussee/caveman · error
store is nil
Error message
store is nil
What it means
Probe verifies a bucket actually supports the operations production retention needs (write, read, version purge) before the service trusts the configuration. It returns 'store is nil' when handed a nil Store — typically because FromEnv returned (nil, nil) in non-production with no S3_ENDPOINT, and the caller passed that straight to Probe.
Solutions
- Skip the probe when no store is configured: check store == nil (or handle FromEnv's (nil, nil)) before calling Probe.
- Check and propagate the error return of FromEnv/New instead of discarding it.
- In production, ensure S3_ENDPOINT is set so FromEnv never legitimately returns a nil store.
- Wire the store through a constructor that fails fast on nil instead of passing raw interface values.
Example fix
// before
store, _ := objectstore.FromEnv()
if err := objectstore.Probe(ctx, store); err != nil { ... }
// after
store, err := objectstore.FromEnv()
if err != nil { return err }
if store != nil {
if err := objectstore.Probe(ctx, store); err != nil { return err }
} Defensive patterns
Strategy: type-guard
Validate before calling
if store == nil {
return errors.New("object store not configured; skipping probe")
} Type guard
func storeConfigured(s objectstore.Store) bool { return s != nil } Try / catch
if store != nil {
if err := objectstore.Probe(ctx, store); err != nil {
return fmt.Errorf("object store probe: %w", err)
}
} Prevention
- Never discard FromEnv/New error returns with _
- Skip health probes when no store is intentionally configured (non-production, no S3_ENDPOINT)
- Fail fast at startup when a nil store would be used later
When it happens
Trigger: Calling Probe(ctx, nil); calling Probe on the result of FromEnv when FromEnv returned nil, nil (no S3_ENDPOINT outside production); a Store interface variable that was never assigned due to an earlier error being ignored.
Common situations: Bootstrapping code that does store, _ := objectstore.FromEnv() and unconditionally probes in dev environments; forgetting to skip the health probe when no store is configured; nil from a failed constructor swallowed by `_`.
Related errors
- objectstore: endpoint and bucket are required
- unknown compression codec
- apiKey, baseURL, and agent are required
- arm must be or
- artifact_id is required
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/a85ae81c529a3e53.
Report an issue: GitHub.
Appendix: source
Thrown at shared/platform/objectstore/objectstore.go:231
func New(cfg Config) (Store, error) {
endpoint := strings.TrimPrefix(strings.TrimPrefix(cfg.Endpoint, "https://"), "http://")
client, err := minio.New(endpoint, &minio.Options{
Creds: credentials.NewStaticV4(cfg.AccessKey, cfg.SecretKey, ""),
Secure: cfg.UseSSL,
Region: cfg.Region,
})
if err != nil {
return nil, fmt.Errorf("objectstore: minio client: %w", err)
}
return &minioStore{client: client, bucket: cfg.Bucket}, nil
}
// Probe proves the operations production retention needs instead of accepting a
// syntactically valid but unusable bucket configuration. The random probe body
// contains no tenant data and every version is removed before success returns.
func Probe(ctx context.Context, store Store) error {
if store == nil {
return errors.New("store is nil")
}
probe := make([]byte, 32)
if _, err := rand.Read(probe); err != nil {
return fmt.Errorf("generate probe: %w", err)
}
key := "_cave_health/" + base64.RawURLEncoding.EncodeToString(probe)
if err := store.Put(ctx, key, probe, "application/octet-stream"); err != nil {
return err
}
cleaned := false
defer func() {
if !cleaned {
// Keep health checks within their caller deadline. A failed probe may
// leave one random, tenant-free canary for lifecycle cleanup; readiness
// must never hang on an unbounded background delete.
_ = PurgeObject(ctx, store, key)
}
}()View on GitHub (pinned to 3ee70a1026)