{"record":{"id":"f098b7d067c75a75","repo":"weaviate/weaviate","slug":"tempvectorforidwithviewthunk-cannot-be-nil","errorCode":null,"errorMessage":"tempVectorForIDWithViewThunk cannot be nil","messagePattern":"tempVectorForIDWithViewThunk cannot be nil","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/vector/hfresh/config.go","lineNumber":85,"sourceCode":"\tDefaultReassignNeighbors         = 8\n\tDefaultMaxDistanceRatio          = 10_000\n)\n\nfunc (c *Config) Validate() error {\n\tc.Logger = common.LoggerOrDiscard(c.Logger)\n\n\tif c.InternalPostingCandidates <= 0 {\n\t\tc.InternalPostingCandidates = DefaultInternalPostingCandidates\n\t}\n\tif c.ReassignNeighbors <= 0 {\n\t\tc.ReassignNeighbors = DefaultReassignNeighbors\n\t}\n\tif c.MaxDistanceRatio <= 0 {\n\t\tc.MaxDistanceRatio = DefaultMaxDistanceRatio\n\t}\n\n\tif c.TempVectorForIDWithViewThunk == nil {\n\t\treturn errors.New(\"tempVectorForIDWithViewThunk cannot be nil\")\n\t}\n\n\tif c.VectorForIDThunk == nil {\n\t\treturn errors.New(\"vectorForIDThunk cannot be nil\")\n\t}\n\n\treturn nil\n}\n\nfunc DefaultConfig() *Config {\n\treturn &Config{\n\t\tLogger:                    logrus.New(),\n\t\tInternalPostingCandidates: DefaultInternalPostingCandidates,\n\t\tReassignNeighbors:         DefaultReassignNeighbors,\n\t\tMaxDistanceRatio:          DefaultMaxDistanceRatio,\n\t\tDistanceProvider:          distancer.NewL2SquaredProvider(),\n\t\tStore:                     StoreConfig{MakeBucketOptions: lsmkv.MakeRegularBucketOptions},\n\t}","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/vector/hfresh/config.go#L67-L103","documentation":"hfresh Config.Validate requires a TempVectorForIDWithViewThunk — the function used to materialize temporary vectors through a storage view — to be non-nil. HFresh cannot read vectors during centroid/posting operations without it, so a nil thunk makes the config invalid and index construction aborts.","triggerScenarios":"Building an HFresh index (New(...) -> Config.Validate) from a Config assembled manually or programmatically where TempVectorForIDWithViewThunk was never assigned.","commonSituations":"Custom/programmatic index construction in tests or internal tooling; wiring bug where only VectorForIDThunk was set; using DefaultConfig() (which leaves thunks nil) without filling them in.","solutions":["Set c.TempVectorForIDWithViewThunk to the shard's view-based vector accessor before calling New/Validate.","Start from DefaultConfig() and assign both thunks rather than building Config from scratch.","If constructing in tests, reuse the same wiring the shard code uses to build the thunk.","Validate the config early at call sites so the nil thunk is caught before index creation proceeds."],"exampleFix":"// before\ncfg := hfresh.DefaultConfig()\ncfg.VectorForIDThunk = store.VectorForIDThunk\n// after\ncfg := hfresh.DefaultConfig()\ncfg.VectorForIDThunk = store.VectorForIDThunk\ncfg.TempVectorForIDWithViewThunk = store.TempVectorForIDWithViewThunk","handlingStrategy":"validation","validationCode":"if cfg.TempVectorForIDWithViewThunk == nil {\n    return errors.New(\"hfresh config: TempVectorForIDWithViewThunk must be set\")\n}\nif err := cfg.Validate(); err != nil {\n    return err\n}","typeGuard":"func validHFreshConfig(c *hfresh.Config) bool {\n    return c != nil &&\n        c.TempVectorForIDWithViewThunk != nil &&\n        c.VectorForIDThunk != nil\n}","tryCatchPattern":"if err := cfg.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"tempVectorForIDWithViewThunk\") {\n        return fmt.Errorf(\"config wiring bug: %w\", err)\n    }\n    return err\n}","preventionTips":["Always build hfresh configs from a helper that sets both thunks","Never start from DefaultConfig() without assigning thunks","Validate configs at construction, not deep inside index startup","Keep a test fixture that constructs a fully wired Config"],"tags":["go","hfresh","config","validation"],"backgroundTag":"missing-required-config-field","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"}