weaviate/weaviate · error

class must be set

Error message

class must be set

What it means

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.

Source

Thrown at usecases/classification/validation.go:55

		errors:             errorcompounder.NewSafe(),
		subject:            subject,
	}
}

func (v *Validator) Do() error {
	v.validate()

	err := v.errors.First()
	if err != nil {
		return fmt.Errorf("invalid classification: %w", err)
	}

	return nil
}

func (v *Validator) validate() {
	if v.subject.Class == "" {
		v.errors.Add(fmt.Errorf("class must be set"))
		return
	}

	class, err := v.authorizedGetClass(v.subject.Class)
	if err != nil {
		v.errors.Add(err)
		return
	}
	if class == nil {
		v.errors.Addf("class '%s' not found in schema", v.subject.Class)
		return
	}

	v.contextualTypeFeasibility()
	v.knnTypeFeasibility()
	v.basedOnProperties(class)
	v.classifyProperties(class)
}

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Add the 'class' field to the classification request body with the name of the collection to classify
  2. Verify the class name exactly matches an existing collection (case-sensitive)
  3. Check the client-side object construction so the field is not dropped when empty

Example fix

// before
{"sourceWhere": {...}, "targetWhere": {...}, "classifyProperties": ["tags"]}
// after
{"class": "Article", "sourceWhere": {...}, "targetWhere": {...}, "classifyProperties": ["tags"]}
Defensive patterns

Strategy: validation

Validate before calling

if req.Class == "" {
    return fmt.Errorf("classification request requires a non-empty 'class' field")
}

Prevention

When it happens

Trigger: POST /v1/classification with a body omitting the 'class' field, or a client SDK serializing a classification request with class:"".

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/4d51a807d509cd4a. Report an issue: GitHub.