{"record":{"id":"c6f7cd6b1b410bb4","repo":"gastownhall/beads","slug":"backend-must-be-set","errorCode":null,"errorMessage":"backend must be set","messagePattern":"backend must be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dbproxy/proxy/backend.go","lineNumber":45,"sourceCode":"}\n\nfunc (b Backend) String() string { return string(b) }\n\n// Valid reports whether b is one of the recognized constants.\nfunc (b Backend) Valid() bool {\n\tfor _, k := range knownBackends {\n\t\tif b == k {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// Validate returns nil if b is non-empty and recognized; otherwise it\n// returns a descriptive error listing the supported set.\nfunc (b Backend) Validate() error {\n\tif b == \"\" {\n\t\treturn errors.New(\"backend must be set\")\n\t}\n\tif !b.Valid() {\n\t\treturn fmt.Errorf(\"unknown backend %q (want one of: %s)\", string(b), strings.Join(KnownBackendNames(), \", \"))\n\t}\n\treturn nil\n}\n\n// KnownBackendNames returns the recognized backend identifiers as strings,\n// in display order. Useful for CLI help text and validation error messages.\nfunc KnownBackendNames() []string {\n\tout := make([]string, len(knownBackends))\n\tfor i, k := range knownBackends {\n\t\tout[i] = string(k)\n\t}\n\treturn out\n}\n","sourceCodeStart":27,"sourceCodeEnd":62,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dbproxy/proxy/backend.go#L27-L62","documentation":"Backend.Validate returns this error when no backend was specified (empty string). The backend name selects which storage engine implementation the proxy/managed child runs, so an empty value is always a configuration mistake rather than a runtime failure.","triggerScenarios":"Calling Backend(\"\").Validate(), directly or transitively through NewDoltServerUOWProvider when a Backend config field was never set.","commonSituations":"Constructing a config struct without filling the Backend field; loading config from YAML/JSON where the key is absent; zero-valued struct passed to NewDoltServerUOWProvider.","solutions":["Set the Backend field to a supported value (see KnownBackendNames()) before calling Validate/NewDoltServerUOWProvider","Check the empty string early in config loading and emit a clear user-facing message","Call b.Validate() right after unmarshalling config to fail fast"],"exampleFix":"// before\nvar cfg Config // Backend left zero-value\np, err := proxy.NewDoltServerUOWProvider(cfg)\n// after\ncfg.Backend = proxy.BackendDolt\nif err := cfg.Backend.Validate(); err != nil { return err }\np, err := proxy.NewDoltServerUOWProvider(cfg)","handlingStrategy":"validation","validationCode":"if cfg.Backend == \"\" { return errors.New(\"backend must be set: one of \" + strings.Join(proxy.KnownBackendNames(), \", \")) }\nif err := cfg.Backend.Validate(); err != nil { return err }","typeGuard":"func backendSet(b proxy.Backend) bool { return b != \"\" }","tryCatchPattern":"if err := b.Validate(); err != nil {\n    return fmt.Errorf(\"invalid backend config: %w\", err)\n}","preventionTips":["Validate config right after unmarshalling","Provide defaults for Backend in config loading","Surface KnownBackendNames() in CLI help"],"tags":["configuration","backend","validation"],"backgroundTag":"missing-config-value","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}