JuliusBrussee/caveman · error
sanitize row
Error message
sanitize row %d: %w
What it means
After the size check, Parse runs telemetry.SanitizeAttributes on each row's attribute map; if sanitization fails (attributes cannot be made safe/valid), the import aborts with this wrapped error identifying the failing row. The %w preserves the underlying sanitize error for diagnosis.
Solutions
- Read the wrapped underlying error to see which attribute key/value failed sanitization
- Clean or drop offending attributes in the source data before import
- Sanitize attributes at export time so imports receive already-conforming maps
- Check telemetry.SanitizeAttributes' constraints and pre-validate rows with the same function
Example fix
// before
attrs["llm.prompt"] = hugeUntrustedString
// after: drop or pre-clean non-conforming keys
for k, v := range attrs {
if !validAttrKey(k) || len(v) > maxAttrValue { delete(attrs, k) }
} Defensive patterns
Strategy: validation
Validate before calling
for i, row := range rows {
if _, err := telemetry.SanitizeAttributes(row.Attributes); err != nil {
return fmt.Errorf("row %d attributes: %w", i, err)
}
} Try / catch
rows, err := importers.Parse(data, opts)
if err != nil {
if strings.Contains(err.Error(), "sanitize row") {
// inspect row attributes; drop/clean non-conforming keys, then re-import
return fmt.Errorf("attribute sanitization failed: %w", err)
}
return err
} Prevention
- Pre-sanitize attributes with telemetry.SanitizeAttributes before import
- Restrict imported attributes to a known allowlist of keys
- Reject attribute values that are oversized or contain forbidden characters at export time
- Keep source formats' attribute conventions aligned with telemetry constraints
When it happens
Trigger: A parsed row's Attributes map contains values SanitizeAttributes rejects — e.g. invalid keys, oversized or non-conformant attribute values that violate the telemetry attribute constraints.
Common situations: Importer formats copying arbitrary user fields into attributes; attribute keys with forbidden characters from third-party exporters; extremely large attribute values; mixing sources with incompatible attribute conventions.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- generic decode: expected a JSON array or
- helicone decode
- Install caveman-middleware[anthropic] to use the Anthropic…
- Install caveman-middleware[langchain] to use the LangChain…
- Install caveman-middleware[openai] to use the OpenAI adapter
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/48d3261c8b198567.
Report an issue: GitHub.
Appendix: source
Thrown at shared/platform/importers/importers.go:103
rows, err = parseLangfuse(data, opts)
case FormatHelicone:
rows, err = parseHelicone(data, opts)
case FormatGeneric:
rows, err = parseGeneric(data, opts)
default:
// fail-closed: unknown formats are an error, never a silent pass-through.
return nil, Summary{}, fmt.Errorf("unknown import format %q: supported formats are otlp, caveman-jsonl, langfuse, helicone, generic", format)
}
if err != nil {
return nil, Summary{}, err
}
for i := range rows {
if len(rows[i].EventsJSON) > telemetry.MaxEventsBytes {
return nil, Summary{}, fmt.Errorf("sanitize row %d: events exceed %d bytes", i, telemetry.MaxEventsBytes)
}
sanitized, sanitizeErr := telemetry.SanitizeAttributes(rows[i].Attributes)
if sanitizeErr != nil {
return nil, Summary{}, fmt.Errorf("sanitize row %d: %w", i, sanitizeErr)
}
rows[i].Attributes = sanitized
}
return rows, Summary{Format: format, RowCount: len(rows)}, nil
}
// ---------------------------------------------------------------------------
// Shared helpers
// ---------------------------------------------------------------------------
// chTimeLayout is the ClickHouse DateTime64 textual layout the gateway writer
// uses; importers must produce the same shape ("2006-01-02 15:04:05.000").
const chTimeLayout = "2006-01-02 15:04:05.000"
// applyScope stamps the authenticated org/project onto a span and fills the
// honest defaults that the spans schema expects for non-null operation. It is
// called for EVERY produced span so the uploaded file can never set org/project.
func applyScope(sp *Span, opts Options) {View on GitHub (pinned to 3ee70a1026)