{"record":{"id":"4d51a807d509cd4a","repo":"weaviate/weaviate","slug":"class-must-be-set","errorCode":null,"errorMessage":"class must be set","messagePattern":"class must be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"usecases/classification/validation.go","lineNumber":55,"sourceCode":"\t\terrors:             errorcompounder.NewSafe(),\n\t\tsubject:            subject,\n\t}\n}\n\nfunc (v *Validator) Do() error {\n\tv.validate()\n\n\terr := v.errors.First()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid classification: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (v *Validator) validate() {\n\tif v.subject.Class == \"\" {\n\t\tv.errors.Add(fmt.Errorf(\"class must be set\"))\n\t\treturn\n\t}\n\n\tclass, err := v.authorizedGetClass(v.subject.Class)\n\tif err != nil {\n\t\tv.errors.Add(err)\n\t\treturn\n\t}\n\tif class == nil {\n\t\tv.errors.Addf(\"class '%s' not found in schema\", v.subject.Class)\n\t\treturn\n\t}\n\n\tv.contextualTypeFeasibility()\n\tv.knnTypeFeasibility()\n\tv.basedOnProperties(class)\n\tv.classifyProperties(class)\n}","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/usecases/classification/validation.go#L37-L73","documentation":"The classification Validator requires the request to name a target class. When subject.Class is the empty string, validate() immediately records \"class must be set\" and aborts before any schema lookup or authorization, because classification without a class has nothing to operate on. The validator collects errors into v.errors, which are surfaced together to the caller after validate finishes.","triggerScenarios":"POST /v1/classification with a body omitting the 'class' field, or a client SDK serializing a classification request with class:\"\".","commonSituations":"Hand-written curl/JSON payloads missing 'class'; dynamically built requests where the class variable was empty; clients migrating from APIs where class was inferred from a source/target specification.","solutions":["Add the 'class' field to the classification request body with the name of the collection to classify","Verify the class name exactly matches an existing collection (case-sensitive)","Check the client-side object construction so the field is not dropped when empty"],"exampleFix":"// before\n{\"sourceWhere\": {...}, \"targetWhere\": {...}, \"classifyProperties\": [\"tags\"]}\n// after\n{\"class\": \"Article\", \"sourceWhere\": {...}, \"targetWhere\": {...}, \"classifyProperties\": [\"tags\"]}","handlingStrategy":"validation","validationCode":"if req.Class == \"\" {\n    return fmt.Errorf(\"classification request requires a non-empty 'class' field\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include 'class' in classification payloads; make it a required field in client SDKs","Validate the request body against the classification schema before POSTing","Test classification requests with a schema validator in CI"],"tags":["classification","validation","missing-field","rest-api"],"backgroundTag":"missing-required-argument","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"}