{"record":{"id":"cd69656f08929b93","repo":"weaviate/weaviate","slug":"drop-vector-index-payload-missing-collection","errorCode":null,"errorMessage":"drop-vector-index payload missing collection","messagePattern":"drop-vector-index payload missing collection","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/drop_vector_index_payload.go","lineNumber":443,"sourceCode":"}\n\nfunc (p *DropVectorIndexTaskPayload) encode() ([]byte, error) {\n\treturn json.Marshal(p)\n}\n\n// DecodeDropVectorIndexTaskPayload decodes and validates a drop-vector task\n// payload; the single decode path for out-of-package callers (REST enqueuer).\nfunc DecodeDropVectorIndexTaskPayload(data []byte) (*DropVectorIndexTaskPayload, error) {\n\treturn decodeDropVectorIndexPayload(data)\n}\n\nfunc decodeDropVectorIndexPayload(data []byte) (*DropVectorIndexTaskPayload, error) {\n\tvar p DropVectorIndexTaskPayload\n\tif err := json.Unmarshal(data, &p); err != nil {\n\t\treturn nil, fmt.Errorf(\"unmarshal drop-vector-index payload: %w\", err)\n\t}\n\tif p.Collection == \"\" {\n\t\treturn nil, fmt.Errorf(\"drop-vector-index payload missing collection\")\n\t}\n\tif len(p.Targets) == 0 {\n\t\treturn nil, fmt.Errorf(\"drop-vector-index payload missing targets\")\n\t}\n\tfor _, t := range p.Targets {\n\t\t// Targets are filepath.Joined and os.RemoveAll'd by removeVectorIndexFiles;\n\t\t// reject empty / separators / \"..\" so a target can't escape the shard dir.\n\t\tif t == \"\" || strings.ContainsAny(t, `/\\`) || strings.Contains(t, \"..\") {\n\t\t\treturn nil, fmt.Errorf(\"drop-vector-index payload has an invalid target name %q\", t)\n\t\t}\n\t}\n\tif p.OpID == \"\" {\n\t\treturn nil, fmt.Errorf(\"drop-vector-index payload missing opId\")\n\t}\n\treturn &p, nil\n}\n\n// ExtractDropVectorIndexTaskTargets is the target extractor registered with","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/drop_vector_index_payload.go#L425-L461","documentation":"After unmarshaling, decodeDropVectorIndexPayload requires p.Collection to be non-empty; a drop-vector task without a target collection is meaningless and would otherwise trigger unsafe cross-collection matching, so it is rejected at decode time.","triggerScenarios":"Enqueuing or replaying a drop-vector task whose payload was built without setting Collection — a producer bug, hand-crafted payload, or partial JSON missing the collection field.","commonSituations":"Custom tooling that constructs drop-vector task payloads; version skew where an older producer omitted a now-required field; truncated JSON that zero-valued the struct.","solutions":["Fix the producer to set Collection in DropVectorIndexTaskPayload before enqueue","Delete and re-enqueue the malformed task via reconciliation","Add a pre-enqueue validation that Collection != \"\"","Check the code path that serialized the payload for field omission"],"exampleFix":"// before\npayload := DropVectorIndexTaskPayload{Targets: []string{\"vec_a\"}}\n// after\npayload := DropVectorIndexTaskPayload{Collection: \"Article\", Targets: []string{\"vec_a\"}}","handlingStrategy":"validation","validationCode":"if payload.Collection == \"\" {\n    return fmt.Errorf(\"refusing to enqueue: collection is required\")\n}\nif len(payload.Targets) == 0 {\n    return fmt.Errorf(\"refusing to enqueue: at least one target required\")\n}","typeGuard":"func (p DropVectorIndexTaskPayload) Valid() bool {\n    return p.Collection != \"\" && len(p.Targets) > 0\n}","tryCatchPattern":"if _, err := decodeDropVectorIndexPayload(raw); err != nil {\n    if strings.Contains(err.Error(), \"missing collection\") {\n        // rebuild the payload with the collection set and re-enqueue\n    }\n}","preventionTips":["Validate payloads at construction time, before enqueue","Require the caller to pass the collection explicitly to any drop-vector helper","Add compile-time/constructor enforcement (no zero-value payload enqueue)","Round-trip test payloads to catch omitted required fields"],"tags":["payload-validation","drop-vector","missing-field"],"backgroundTag":"payload-validation-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"}