{"record":{"id":"547170a68ff8caf0","repo":"weaviate/weaviate","slug":"prepare-context-for-text2vec-contextionary-context","errorCode":null,"errorMessage":"prepare context for text2vec-contextionary-contextual classification","messagePattern":"prepare context for text2vec-contextionary-contextual classification","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/text2vec-contextionary/classification/classifier.go","lineNumber":52,"sourceCode":"func New(vectorizer vectorizer) modulecapabilities.Classifier {\n\treturn &Classifier{vectorizer: vectorizer}\n}\n\nfunc (c *Classifier) Name() string {\n\treturn \"text2vec-contextionary-contextual\"\n}\n\nfunc (c *Classifier) ClassifyFn(params modulecapabilities.ClassifyParams) (modulecapabilities.ClassifyItemFn, error) {\n\tif c.vectorizer == nil {\n\t\treturn nil, errors.Errorf(\"cannot use text2vec-contextionary-contextual \" +\n\t\t\t\"without the respective module\")\n\t}\n\n\t// 1. do preparation here once\n\tpreparedContext, err := c.prepareContextualClassification(params.GetClass, params.VectorRepo,\n\t\tparams.Params, params.Filters, params.UnclassifiedItems)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"prepare context for text2vec-contextionary-contextual classification\")\n\t}\n\n\t// 2. use higher order function to inject preparation data so it is then present for each single run\n\treturn c.makeClassifyItemContextual(preparedContext), nil\n}\n\nfunc (c *Classifier) ParseClassifierSettings(params *models.Classification) error {\n\traw := params.Settings\n\tsettings := &ParamsContextual{}\n\tif raw == nil {\n\t\tsettings.SetDefaults()\n\t\tparams.Settings = settings\n\t\treturn nil\n\t}\n\n\tasMap, ok := raw.(map[string]interface{})\n\tif !ok {\n\t\treturn errors.Errorf(\"settings must be an object got %T\", raw)","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/modules/text2vec-contextionary/classification/classifier.go#L34-L70","documentation":"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.","triggerScenarios":"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.","commonSituations":"Invalid class names or filter paths in the classification request; schema access issues; contextionary inference failing during corpus preparation; very large corpora timing out.","solutions":["Inspect the wrapped inner error for the root cause (class read, filter, or vectorization failure)","Validate class names, source/target properties, and filters in the classification request against the schema","Confirm the contextionary service is healthy and responsive before retrying"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// validate request before submitting\nif className == \"\" || len(sourceProperties) == 0 { return errors.New(\"class and source properties required\") }\n// ensure target class exists in schema\n_, err := client.Schema().ClassGetter().GetClass(className)","typeGuard":null,"tryCatchPattern":"resp, err := client.Classifications().Classify(req)\nif err != nil {\n  if strings.Contains(err.Error(), \"prepare context\") {\n    // log inner cause, verify schema/filters, retry after fixing\n  }\n  return err\n}","preventionTips":["Validate class names and filter syntax against the schema before classification","Ensure the contextionary service is healthy before large classification jobs","Keep classification corpora within reasonable size limits"],"tags":["go","classification","contextionary"],"backgroundTag":"classification-preparation-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"}