{"record":{"id":"6b116db78afb4e6a","repo":"micro/go-micro","slug":"invalid-event-returned-from-stroe","errorCode":null,"errorMessage":"Invalid event returned from stroe","messagePattern":"Invalid event returned from stroe","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"events/store.go","lineNumber":72,"sourceCode":"\t\to(&options)\n\t}\n\n\t// execute the request\n\trecs, err := s.store.Read(topic+joinKey,\n\t\tstore.ReadPrefix(),\n\t\tstore.ReadLimit(options.Limit),\n\t\tstore.ReadOffset(options.Offset),\n\t)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"Error reading from store\")\n\t}\n\n\t// unmarshal the result\n\tresult := make([]*Event, len(recs))\n\tfor i, r := range recs {\n\t\tvar e Event\n\t\tif err := json.Unmarshal(r.Value, &e); err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"Invalid event returned from stroe\")\n\t\t}\n\t\tresult[i] = &e\n\t}\n\n\treturn result, nil\n}\n\n// Write an event to the store\nfunc (s *evStore) Write(event *Event, opts ...WriteOption) error {\n\t// parse the options\n\toptions := WriteOptions{\n\t\tTTL: s.opts.TTL,\n\t}\n\tfor _, o := range opts {\n\t\to(&options)\n\t}\n\n\t// construct the store record","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/events/store.go#L54-L90","documentation":"After reading raw records, evStore.Read unmarshals each record's Value bytes into an Event struct. This error wraps a json.Unmarshal failure, meaning a stored record's payload is not valid JSON for the Event schema. (Note the typo 'stroe' is in the library's message text.)","triggerScenarios":"A record in the store was written by a different/older version of the library with an incompatible Event schema, the record bytes were corrupted, or the store backend returned non-JSON data under the topic prefix.","commonSituations":"Schema drift after upgrading the events package (renamed/retyped Event fields); manual edits or backups restoring incompatible records; a store shared between services writing different payload shapes under the same topic prefix.","solutions":["Identify the offending record and check its JSON against the current Event struct","Migrate or purge records written by the old schema version","Use json tags and tolerant decoding (e.g. keep fields optional) to stay backward compatible","Validate payload shape at write time to prevent corrupt entries","Clear the topic's records if they are disposable and re-publish"],"exampleFix":"// before\ntype Event struct { ID string; Timestamp int64 } // old records store \"time\" as string\njson.Unmarshal(r.Value, &e) // fails on legacy records\n// after\ntype Event struct { ID string; Timestamp int64 }\nvar raw map[string]json.RawMessage\njson.Unmarshal(r.Value, &raw)\n// migrate legacy \"time\" field before decoding into Event","handlingStrategy":"type-guard","validationCode":"func isValidEventJSON(b []byte) bool {\n    var probe map[string]json.RawMessage\n    return json.Unmarshal(b, &probe) == nil && probe[\"id\"] != nil\n}","typeGuard":"func safeDecodeEvent(b []byte) (*events.Event, error) {\n    var e events.Event\n    if err := json.Unmarshal(b, &e); err != nil {\n        return nil, fmt.Errorf(\"skipping malformed record: %w\", err)\n    }\n    return &e, nil\n}","tryCatchPattern":"recs, err := evStore.Read(topic)\nif err != nil {\n    if strings.Contains(err.Error(), \"Invalid event returned from stroe\") {\n        // skip/repair the malformed record instead of failing the whole read\n        log.Printf(\"malformed record: %v\", errors.Cause(err))\n    }\n    return err\n}","preventionTips":["Add json tags to Event fields and keep schema backward compatible","Version your event schema when changing field types","Validate payloads before writing them to the store","Purge or migrate records after upgrading the events library"],"tags":["json","unmarshal","store","schema"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}