JuliusBrussee/caveman · error
catalog is empty
Error message
catalog is empty
What it means
DecodeAndValidate rejects a catalog whose top-level decoded value is empty (no entries decoded). An empty catalog cannot be trusted as routing/pricing truth, so it fails instead of yielding zero entries.
Solutions
- Restore the real catalog content from version control or the generator.
- Check the file is non-empty: wc -c catalog.yaml; fix the pipeline that produced it.
- Verify the loader is pointed at the correct catalog path, not a placeholder.
- Add a pre-flight non-empty check before load in deployment scripts.
Example fix
# before
cat > catalog.yaml <<EOF
EOF
# after
cat > catalog.yaml <<EOF
entries:
- provider: anthropic
model: claude-sonnet
region: us
currency: USD
...
EOF Defensive patterns
Strategy: validation
Validate before calling
if len(bytes.TrimSpace(raw)) == 0 {
return fmt.Errorf("catalog file is empty")
} Try / catch
entries, err := load(path)
if err != nil {
if strings.Contains(err.Error(), "catalog is empty") {
return restoreLastKnownGoodCatalog()
}
return err
} Prevention
- Check file size before load in deploy scripts
- Use atomic writes (temp file + rename) so failed writes can't truncate the catalog
- Keep catalogs in version control for easy restore
- Alert on any pipeline step that writes a zero-byte catalog
When it happens
Trigger: Calling DecodeAndValidate with a YAML file that is empty, whitespace/comment-only, or decodes to a zero-length entry list (e.g. 'entries: []' depending on the target type).
Common situations: A catalog file truncated to zero bytes by a failed write, a CI step that overwrote the catalog with nothing, or an env/config pointing at the wrong (empty) file.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- catalog
- : currency must be USD
- : must be a safe non-empty identifier
- : missing field(s)
- : pricing must be an object
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/ce06c837e6ec0323.
Report an issue: GitHub.
Appendix: source
Thrown at shared/platform/catalog/catalog.go:317
// DecodeAndValidate strictly parses a catalog. Unknown YAML fields, duplicate
// provider/model/region rows, invalid URLs/timestamps, and unsafe prices reject
// the entire file; runtime must never load a plausible partial catalog.
func DecodeAndValidate(raw []byte) ([]Entry, error) {
dec := yaml.NewDecoder(bytes.NewReader(raw))
dec.KnownFields(true)
var decoded []Entry
if err := dec.Decode(&decoded); err != nil {
return nil, err
}
var trailing any
if err := dec.Decode(&trailing); err != io.EOF {
if err == nil {
return nil, fmt.Errorf("multiple YAML documents are not allowed")
}
return nil, err
}
if len(decoded) == 0 {
return nil, fmt.Errorf("catalog is empty")
}
seen := make(map[string]struct{}, len(decoded))
for i, entry := range decoded {
label := fmt.Sprintf("entry %d", i)
if strings.TrimSpace(entry.Provider) == "" || strings.TrimSpace(entry.Model) == "" || strings.TrimSpace(entry.Region) == "" {
return nil, fmt.Errorf("%s: provider, model, and region are required", label)
}
if entry.Currency != "USD" {
return nil, fmt.Errorf("%s %s/%s: unsupported currency %q", label, entry.Provider, entry.Model, entry.Currency)
}
if !cost.ValidPrice(entry.Pricing) {
return nil, fmt.Errorf("%s %s/%s: invalid pricing", label, entry.Provider, entry.Model)
}
verified, err := time.Parse(time.RFC3339, entry.VerifiedAt)
if err != nil || verified.IsZero() {
return nil, fmt.Errorf("%s %s/%s: verified_at must be RFC3339", label, entry.Provider, entry.Model)
}
if verified.After(time.Now().UTC().Add(24 * time.Hour)) {View on GitHub (pinned to 3ee70a1026)