{"record":{"id":"aa029cf1e54b0f22","repo":"Tencent/WeKnora","slug":"sandbox-config-is-missing-required-fields-s-bac","errorCode":null,"errorMessage":"sandbox: config is missing required fields: %s backend requires %s","messagePattern":"sandbox: config is missing required fields: (.+?) backend requires (.+?)","errorType":"validation","errorClass":"ErrSandboxConfigIncomplete","httpStatus":null,"severity":"error","filePath":"internal/sandbox/config_required.go","lineNumber":72,"sourceCode":"\tcase SandboxTypeDocker:\n\t\trequire(\"image\", cfg.DockerImage)\n\t}\n\treturn missing\n}\n\n// RequireCompleteConfig is the error form of MissingRequiredFields, shared by\n// the save path and the resolve path so both reject the same configs with the\n// same wording.\nfunc RequireCompleteConfig(cfg *Config) error {\n\tmissing := MissingRequiredFields(cfg)\n\tif len(missing) == 0 {\n\t\treturn nil\n\t}\n\tprovider := \"\"\n\tif cfg != nil {\n\t\tprovider = string(cfg.Type)\n\t}\n\treturn fmt.Errorf(\n\t\t\"%w: %s backend requires %s\",\n\t\tErrSandboxConfigIncomplete, provider, strings.Join(missing, \", \"),\n\t)\n}\n","sourceCodeStart":54,"sourceCodeEnd":77,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/sandbox/config_required.go#L54-L77","documentation":"RequireCompleteConfig validates that a sandbox config has all required fields for its selected backend type. It returns ErrSandboxConfigIncomplete wrapped with the backend provider name and the comma-separated list of missing fields, so callers can errors.Is() against the sentinel while still seeing which keys to set.","triggerScenarios":"Calling ResolveEffectiveConfig with a SandboxConfig whose Type selects a backend (e.g. docker, cube) but which omits that backend's mandatory settings (e.g. docker host, image, TLS cert dir). The missing fields are enumerated in the error message.","commonSituations":"Partial configs assembled from env vars where only some keys are set; switching sandbox type without migrating the type-specific fields; a defaults merge leaving empty strings that count as missing.","solutions":["Read the error's field list and set each named field on the sandbox config","Run RequireCompleteConfig (or ResolveEffectiveConfig) early at startup to fail fast with the full missing-field list","Ensure the config Type matches the fields you populated — a docker-typed config needs docker settings, not cube ones","Check environment variables/config file for empty-string values that parse as missing"],"exampleFix":"// before\ncfg := &sandbox.Config{Type: sandbox.TypeDocker} // missing host\n// after\ncfg := &sandbox.Config{Type: sandbox.TypeDocker, Docker: sandbox.DockerSettings{Host: \"unix:///var/run/docker.sock\", Image: \"sandbox:latest\"}}\nif err := sandbox.RequireCompleteConfig(cfg); err != nil { log.Fatal(err) }","handlingStrategy":"validation","validationCode":"if err := sandbox.RequireCompleteConfig(cfg); err != nil {\n    if errors.Is(err, sandbox.ErrSandboxConfigIncomplete) {\n        log.Fatalf(\"sandbox config incomplete: %v\", err) // message lists missing fields\n    }\n    return err\n}","typeGuard":"func hasRequiredDockerFields(cfg *sandbox.Config) bool {\n    return cfg != nil && cfg.Type == sandbox.TypeDocker && cfg.Docker.Host != \"\" && cfg.Docker.Image != \"\"\n}","tryCatchPattern":"cfg, err := sandbox.ResolveEffectiveConfig(ctx, raw)\nif err != nil && errors.Is(err, sandbox.ErrSandboxConfigIncomplete) {\n    // parse the 'backend requires ...' tail to surface missing fields to the user\n}","preventionTips":["Call RequireCompleteConfig at process startup, before any sandbox use","Keep one typed config struct per backend and populate all its fields when Type is set","Watch for empty strings from env parsing — they count as missing"],"tags":["sandbox","configuration","validation","docker"],"backgroundTag":"incomplete-configuration","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}