{"record":{"id":"8a34946d407b340b","repo":"Tencent/WeKnora","slug":"errnamedsandboxbackendunsupported","errorCode":"ErrNamedSandboxBackendUnsupported","errorMessage":"%w","messagePattern":"%w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/tenant_sandbox_config.go","lineNumber":402,"sourceCode":"\t}\n\treturn merged, nil\n}\n\nfunc validateSkillRollout(value string) error {\n\tswitch strings.TrimSpace(value) {\n\tcase \"\", types.SkillRolloutNextTurn, types.SkillRolloutNewSession:\n\t\treturn nil\n\tdefault:\n\t\treturn apperrors.NewBadRequestError(\"invalid skill_rollout\")\n\t}\n}\n\nfunc validateNamedSandboxBackend(cfg *types.TenantSandboxConfig) error {\n\tif cfg == nil || strings.TrimSpace(cfg.SandboxType) == \"\" {\n\t\treturn apperrors.NewBadRequestError(\"sandbox backend type is required\")\n\t}\n\tif !sandbox.IsNamedSandboxBackendType(cfg.SandboxType) {\n\t\treturn fmt.Errorf(\"%w\", ErrNamedSandboxBackendUnsupported)\n\t}\n\treturn sandbox.EnsureDockerBackendAllowed(sandbox.SandboxType(cfg.SandboxType))\n}\n\nfunc filterPublicSandboxConfigs(\n\tlist []*types.TenantSandboxConfigEntity,\n) []*types.TenantSandboxConfigEntity {\n\tif len(list) == 0 {\n\t\treturn list\n\t}\n\tout := make([]*types.TenantSandboxConfigEntity, 0, len(list))\n\tfor _, e := range list {\n\t\tif types.IsSandboxWorkspacePolicyRow(e) {\n\t\t\tcontinue\n\t\t}\n\t\tout = append(out, e)\n\t}\n\treturn out","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/tenant_sandbox_config.go#L384-L420","documentation":"validateNamedSandboxBackend rejects a tenant sandbox config whose SandboxType is not a recognized named backend type (sandbox.IsNamedSandboxBackendType returns false), surfacing the sentinel ErrNamedSandboxBackendUnsupported wrapped via %w. Called from Create and Update of tenant sandbox configurations.","triggerScenarios":"Create or Update of a TenantSandboxConfig with a SandboxType string that is not in the set of named backend types (typo, wrong casing, removed/renamed backend, empty-after-trim handled separately).","commonSituations":"Typo in sandbox type in tenant config payload (e.g. \"docker2\", \"gVisor\"); casing mismatch (\"Docker\" vs \"docker\"); backend type removed in a version upgrade; JSON field misspelled so an unexpected value lands in SandboxType.","solutions":["Use one of the supported named sandbox backend types exactly as defined by sandbox.IsNamedSandboxBackendType (e.g. \"docker\")","Check config/JSON spelling and casing of the sandbox_type field","Consult the current version's supported backend list — types may change between releases","Ensure validation errors are mapped to a 400 response listing valid values"],"exampleFix":"// before\ncfg.SandboxType = \"Docker\" // unsupported casing\n// after\ncfg.SandboxType = string(sandbox.SandboxTypeDocker)","handlingStrategy":"validation","validationCode":"if !sandbox.IsNamedSandboxBackendType(cfg.SandboxType) {\n    return errors.New(\"sandbox_type must be one of the supported named backends\")\n}","typeGuard":null,"tryCatchPattern":"if errors.Is(err, apperrors.ErrNamedSandboxBackendUnsupported) || strings.Contains(err.Error(), \"unsupported\") {\n    // return 400 with list of valid backend types\n}","preventionTips":["Use the sandbox.SandboxType constants, never raw literals","Validate SandboxType client-side against the supported list","Add schema/enum validation on the sandbox_type field","Re-check valid values after version upgrades"],"tags":["sandbox","validation","unsupported-value","config"],"backgroundTag":"unsupported-enum-value","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}