{"record":{"id":"50d41b65df003004","repo":"JuliusBrussee/caveman","slug":"unknown-import-format-q-supported-formats-are-ot","errorCode":null,"errorMessage":"unknown import format %q: supported formats are otlp, caveman-jsonl, langfuse, helicone, generic","messagePattern":"unknown import format %q: supported formats are otlp, caveman-jsonl, langfuse, helicone, generic","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/importers/importers.go","lineNumber":92,"sourceCode":"\t}\n\tvar (\n\t\trows []Span\n\t\terr  error\n\t)\n\tswitch format {\n\tcase FormatOTLP:\n\t\trows, err = parseOTLP(data, opts)\n\tcase FormatCavemanJSONL:\n\t\trows, err = parseCavemanJSONL(data, opts)\n\tcase FormatLangfuse:\n\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// ---------------------------------------------------------------------------","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/shared/platform/importers/importers.go#L74-L110","documentation":"Import dispatches on the format string and this default branch fires when the format matches none of FormatOTLP, FormatCavemanJSONL, FormatLangfuse, FormatHelicone, FormatGeneric. The comment marks it fail-closed by design: unknown formats are never silently passed through. The error enumerates the supported set so the caller can self-correct.","triggerScenarios":"Calling Import with an empty format string; passing 'json' or 'otlp-json' instead of the exact constants; case mismatch ('OTLP' vs 'otlp') since dispatch is exact-match on the constant values; passing a newly added format name not yet in this switch.","commonSituations":"Format taken from a CLI flag or HTTP header without validation; version skew where the caller knows a format this build doesn't; trailing whitespace in the format string; typo in configuration YAML.","solutions":["Use the exported Format* constants (importers.FormatOTLP etc.) instead of raw strings","If the string comes from user input, validate it against the allowed set before calling Import","Trim whitespace and lowercase the input if it originates from config","Upgrade the shared/platform package if you expect a format added in a newer version"],"exampleFix":"// before\nrows, sum, err := importers.Import(\"otlp-json\", data, opts)\n\n// after\nrows, sum, err := importers.Import(importers.FormatOTLP, data, opts)","handlingStrategy":"type-guard","validationCode":"var supportedFormats = map[string]bool{\n\timporters.FormatOTLP: true, importers.FormatCavemanJSONL: true,\n\timporters.FormatLangfuse: true, importers.FormatHelicone: true,\n\timporters.FormatGeneric: true,\n}\nfunc formatSupported(f string) bool { return supportedFormats[strings.TrimSpace(f)] }","typeGuard":"func formatSupported(f string) bool {\n\tswitch strings.TrimSpace(f) {\n\tcase importers.FormatOTLP, importers.FormatCavemanJSONL, importers.FormatLangfuse,\n\t\timporters.FormatHelicone, importers.FormatGeneric:\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":"if !formatSupported(fmtStr) { return fmt.Errorf(\"unsupported format %q (typo?)\", fmtStr) } rows, sum, err := importers.Import(fmtStr, data, opts)","preventionTips":["Only reference the exported Format* constants, never string literals","Validate the format string at the CLI/HTTP boundary before it reaches Import","Fail startup if configured format is unknown"],"tags":["go","import","format-dispatch","validation"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}