{"record":{"id":"d706ff080fd956c3","repo":"JuliusBrussee/caveman","slug":"helicone-decode-w","errorCode":null,"errorMessage":"helicone decode: %w","messagePattern":"helicone decode: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/importers/helicone.go","lineNumber":67,"sourceCode":"\trecs, err := decodeHelicone(data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trows := make([]Span, 0, len(recs))\n\tfor _, rec := range recs {\n\t\trows = append(rows, mapHelicone(rec, opts))\n\t}\n\treturn rows, nil\n}\n\nfunc decodeHelicone(data []byte) ([]heliconeRecord, error) {\n\tvar env heliconeEnvelope\n\tif err := json.Unmarshal(data, &env); err == nil && env.Data != nil {\n\t\treturn env.Data, nil\n\t}\n\tvar arr []heliconeRecord\n\tif err := json.Unmarshal(data, &arr); err != nil {\n\t\treturn nil, fmt.Errorf(\"helicone decode: %w\", err)\n\t}\n\treturn arr, nil\n}\n\nfunc mapHelicone(rec heliconeRecord, opts Options) Span {\n\tts, _ := parseTimeFlexible(rec.CreatedAt)\n\n\tmodel := rec.Response.Model\n\tif model == \"\" {\n\t\tmodel = rec.Request.Model\n\t}\n\tprovider := rec.Provider\n\tif provider == \"\" {\n\t\tprovider = rec.Request.Provider\n\t}\n\n\t// 2xx is ok; anything else (including 0/unknown) is an error.\n\tstatus := \"ok\"","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/importers/helicone.go#L49-L85","documentation":"decodeHelicone first tries the {\"data\":[...]} envelope, then a bare array of heliconeRecord objects. This error wraps the underlying json.Unmarshal error when neither shape decodes, meaning the payload is not valid JSON in either accepted Helicone layout. The wrapped error names the exact JSON syntax/type problem.","triggerScenarios":"Calling Parse with FormatHelicone on data that is not a JSON array nor a {\"data\":[...]} object: malformed JSON, a JSON object without a `data` key, or a `data`/array whose elements do not match heliconeRecord field types (e.g. numeric request_body where a string is expected).","commonSituations":"Feeding Langfuse observations JSON to the Helicone importer; a truncated download; an API error body ({\"error\":...}) passed through; double-encoded JSON (a JSON string containing JSON); elements with wrong field types after an exporter version change.","solutions":["Validate the payload parses as JSON and is either a bare array or an object with a `data` array","Read the wrapped %w error to find the exact JSON offset/type failure and fix that field","Ensure you are using the Helicone export format, not Langfuse/OTLP JSON","Check heliconeRecord field types (all strings) against your data; pre-convert numeric fields to strings"],"exampleFix":"// before (wrong envelope for helicone)\n{\"observations\":[{\"id\":\"1\"}]}\n// after\n{\"data\":[{\"request_id\":\"1\",\"created_at\":\"2024-01-01T00:00:00Z\"}]}","handlingStrategy":"validation","validationCode":"func isHeliconePayload(data []byte) bool {\n  var env struct{ Data []json.RawMessage `json:\"data\"` }\n  if err := json.Unmarshal(data, &env); err == nil && env.Data != nil { return true }\n  var arr []json.RawMessage\n  return json.Unmarshal(data, &arr) == nil\n}","typeGuard":null,"tryCatchPattern":"rows, err := importers.Parse(data, opts)\nif err != nil {\n  if strings.Contains(err.Error(), \"helicone decode:\") {\n    return fmt.Errorf(\"payload is not a helicone array or {\\\"data\\\":[...]}: %w\", err)\n  }\n  return err\n}","preventionTips":["Validate JSON syntax before import","Match the payload to the correct importer format (helicone vs langfuse vs generic)","Check that array elements are objects with string fields matching heliconeRecord","Beware of truncated downloads and double-encoded JSON"],"tags":["json","helicone","import"],"backgroundTag":"json-unmarshal-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"}