{"record":{"id":"1371c0c4a6987bd3","repo":"weaviate/weaviate","slug":"parsing-class-q-w","errorCode":null,"errorMessage":"parsing class %q: %w","messagePattern":"parsing class %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"cluster/schema/schema.go","lineNumber":787,"sourceCode":"}\n\nfunc (s *schema) RestoreLegacy(data []byte, parser Parser) error {\n\tsnap := snapshot{}\n\tif err := json.Unmarshal(data, &snap); err != nil {\n\t\treturn fmt.Errorf(\"restore snapshot: decode json: %w\", err)\n\t}\n\n\tif snap.Classes == nil {\n\t\tsnap.Classes = make(map[string]*metaClass)\n\t}\n\n\treturn s.restore(snap.Classes, parser)\n}\n\nfunc (s *schema) restore(classes map[string]*metaClass, parser Parser) error {\n\tfor _, cls := range classes {\n\t\tif err := parser.ParseClass(&cls.Class); err != nil { // should not fail\n\t\t\treturn fmt.Errorf(\"parsing class %q: %w\", cls.Class.Class, err) // schema might be corrupted\n\t\t}\n\t\tcls.Sharding.SetLocalName(s.nodeID)\n\t}\n\ts.replaceClasses(classes)\n\treturn nil\n}\n\nfunc (s *schema) RestoreAlias(data []byte) error {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\n\ts.aliases = make(map[string]string)\n\tif err := json.Unmarshal(data, &s.aliases); err != nil {\n\t\treturn fmt.Errorf(\"restore alias: parse json: %w\", err)\n\t}\n\treturn nil\n}\n","sourceCodeStart":769,"sourceCodeEnd":805,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/cluster/schema/schema.go#L769-L805","documentation":"During schema restore, every class in the decoded snapshot is run through parser.ParseClass to validate and normalize it. If parsing fails for any class, restore aborts with this wrapped error naming the offending class. The code comment notes this 'should not fail' in normal operation, so a failure means the stored schema is corrupted or contains classes that no longer satisfy the parser's validation rules.","triggerScenarios":"Calling Restore or RestoreLegacy where any metaClass in the snapshot fails ParseClass — e.g. a class missing required fields, an invalid vectorizer/module configuration, or an unparsable inverted-index/sharding config in the snapshot.","commonSituations":"Restoring a snapshot from an older Weaviate version whose class definitions fail the current parser's validation; hand-edited schema snapshots; partially written snapshot data after a crash; module configs referencing modules not configured on the new node.","solutions":["Inspect the named class in the snapshot file and fix the invalid field (missing class name, bad vectorizer/module config, malformed property definitions).","Restore a snapshot from the same or compatible Weaviate version; upgrade-incompatible snapshots must go through export/import of the schema instead of file-level restore.","Remove the corrupt class entry from the snapshot if it is no longer needed, then retry restore.","Rebuild the node's persistence directory from a verified backup or re-bootstrap the node into the cluster so Raft replays a good snapshot."],"exampleFix":"// before: restoring a snapshot with an invalid class config\nerr := schema.Restore(data, parser)\n// -> \"parsing class \\\"Article\\\": ...\"\n\n// after: validate each class up front and repair before restore\nvar snap snapshot\njson.Unmarshal(data, &snap)\nfor name, cls := range snap.Classes {\n    if err := parser.ParseClass(&cls.Class); err != nil {\n        log.Fatalf(\"class %q in snapshot is invalid, repair or remove it: %v\", name, err)\n    }\n}\nerr := schema.Restore(data, parser)","handlingStrategy":"try-catch","validationCode":"var snap snapshot\nif err := json.Unmarshal(data, &snap); err != nil {\n    return err\n}\nfor name, cls := range snap.Classes {\n    if err := parser.ParseClass(&cls.Class); err != nil {\n        return fmt.Errorf(\"class %q in snapshot is invalid: %w\", name, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := schema.Restore(data, parser); err != nil {\n    // err names the offending class\n    log.Printf(\"schema restore failed, inspect the named class: %v\", err)\n}","preventionTips":["Restore snapshots only on the same or forward-compatible Weaviate version.","Validate schema exports (class configs, module settings) before snapshotting.","Keep module/vectorizer configuration identical across cluster nodes.","Avoid manual edits to schema snapshot files."],"tags":["schema","validation","snapshot-restore","raft"],"backgroundTag":"schema-restore-failed","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}