weaviate/weaviate · error

prepare context for text2vec-contextionary-contextual classi

Error message

prepare context for text2vec-contextionary-contextual classification

What it means

Wraps any error from prepareContextualClassification when starting a contextual classification job. The preparation phase (fetching class data, vectorizing the contextual corpus) failed, so the classification cannot be scheduled. The underlying error is preserved and this wrapper adds context about which stage failed.

Source

Thrown at modules/text2vec-contextionary/classification/classifier.go:52

func New(vectorizer vectorizer) modulecapabilities.Classifier {
	return &Classifier{vectorizer: vectorizer}
}

func (c *Classifier) Name() string {
	return "text2vec-contextionary-contextual"
}

func (c *Classifier) ClassifyFn(params modulecapabilities.ClassifyParams) (modulecapabilities.ClassifyItemFn, error) {
	if c.vectorizer == nil {
		return nil, errors.Errorf("cannot use text2vec-contextionary-contextual " +
			"without the respective module")
	}

	// 1. do preparation here once
	preparedContext, err := c.prepareContextualClassification(params.GetClass, params.VectorRepo,
		params.Params, params.Filters, params.UnclassifiedItems)
	if err != nil {
		return nil, errors.Wrap(err, "prepare context for text2vec-contextionary-contextual classification")
	}

	// 2. use higher order function to inject preparation data so it is then present for each single run
	return c.makeClassifyItemContextual(preparedContext), nil
}

func (c *Classifier) ParseClassifierSettings(params *models.Classification) error {
	raw := params.Settings
	settings := &ParamsContextual{}
	if raw == nil {
		settings.SetDefaults()
		params.Settings = settings
		return nil
	}

	asMap, ok := raw.(map[string]interface{})
	if !ok {
		return errors.Errorf("settings must be an object got %T", raw)

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Inspect the wrapped inner error for the root cause (class read, filter, or vectorization failure)
  2. Validate class names, source/target properties, and filters in the classification request against the schema
  3. Confirm the contextionary service is healthy and responsive before retrying
Defensive patterns

Strategy: try-catch

Validate before calling

// validate request before submitting
if className == "" || len(sourceProperties) == 0 { return errors.New("class and source properties required") }
// ensure target class exists in schema
_, err := client.Schema().ClassGetter().GetClass(className)

Try / catch

resp, err := client.Classifications().Classify(req)
if err != nil {
  if strings.Contains(err.Error(), "prepare context") {
    // log inner cause, verify schema/filters, retry after fixing
  }
  return err
}

Prevention

When it happens

Trigger: POSTing a classification with type text2vec-contextionary-contextual when the source/target class cannot be read, the vector repo errors, filters are invalid, or vectorization of the context fails.

Common situations: Invalid class names or filter paths in the classification request; schema access issues; contextionary inference failing during corpus preparation; very large corpora timing out.

Related errors


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