{"record":{"id":"48d3261c8b198567","repo":"JuliusBrussee/caveman","slug":"sanitize-row-d-w","errorCode":null,"errorMessage":"sanitize row %d: %w","messagePattern":"sanitize row (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/importers/importers.go","lineNumber":103,"sourceCode":"\t\trows, err = parseLangfuse(data, opts)\n\tcase FormatHelicone:\n\t\trows, err = parseHelicone(data, opts)\n\tcase FormatGeneric:\n\t\trows, err = parseGeneric(data, opts)\n\tdefault:\n\t\t// fail-closed: unknown formats are an error, never a silent pass-through.\n\t\treturn nil, Summary{}, fmt.Errorf(\"unknown import format %q: supported formats are otlp, caveman-jsonl, langfuse, helicone, generic\", format)\n\t}\n\tif err != nil {\n\t\treturn nil, Summary{}, err\n\t}\n\tfor i := range rows {\n\t\tif len(rows[i].EventsJSON) > telemetry.MaxEventsBytes {\n\t\t\treturn nil, Summary{}, fmt.Errorf(\"sanitize row %d: events exceed %d bytes\", i, telemetry.MaxEventsBytes)\n\t\t}\n\t\tsanitized, sanitizeErr := telemetry.SanitizeAttributes(rows[i].Attributes)\n\t\tif sanitizeErr != nil {\n\t\t\treturn nil, Summary{}, fmt.Errorf(\"sanitize row %d: %w\", i, sanitizeErr)\n\t\t}\n\t\trows[i].Attributes = sanitized\n\t}\n\treturn rows, Summary{Format: format, RowCount: len(rows)}, nil\n}\n\n// ---------------------------------------------------------------------------\n// Shared helpers\n// ---------------------------------------------------------------------------\n\n// chTimeLayout is the ClickHouse DateTime64 textual layout the gateway writer\n// uses; importers must produce the same shape (\"2006-01-02 15:04:05.000\").\nconst chTimeLayout = \"2006-01-02 15:04:05.000\"\n\n// applyScope stamps the authenticated org/project onto a span and fills the\n// honest defaults that the spans schema expects for non-null operation. It is\n// called for EVERY produced span so the uploaded file can never set org/project.\nfunc applyScope(sp *Span, opts Options) {","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/importers/importers.go#L85-L121","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nattrs[\"llm.prompt\"] = hugeUntrustedString\n// after: drop or pre-clean non-conforming keys\nfor k, v := range attrs {\n  if !validAttrKey(k) || len(v) > maxAttrValue { delete(attrs, k) }\n}","handlingStrategy":"validation","validationCode":"for i, row := range rows {\n  if _, err := telemetry.SanitizeAttributes(row.Attributes); err != nil {\n    return fmt.Errorf(\"row %d attributes: %w\", i, err)\n  }\n}","typeGuard":null,"tryCatchPattern":"rows, err := importers.Parse(data, opts)\nif err != nil {\n  if strings.Contains(err.Error(), \"sanitize row\") {\n    // inspect row attributes; drop/clean non-conforming keys, then re-import\n    return fmt.Errorf(\"attribute sanitization failed: %w\", err)\n  }\n  return err\n}","preventionTips":["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"],"tags":["import","attributes","sanitization"],"backgroundTag":"schema-validation-failed","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}