{"record":{"id":"17b90d978ce727bd","repo":"Tencent/WeKnora","slug":"unknown-sandbox-type-s","errorCode":null,"errorMessage":"unknown sandbox type: %s","messagePattern":"unknown sandbox type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sandbox/manager.go","lineNumber":62,"sourceCode":"func (m *DefaultManager) initializeSandbox(ctx context.Context) error {\n\tswitch m.config.Type {\n\tcase SandboxTypeDisabled:\n\t\tm.sandbox = &disabledSandbox{}\n\t\treturn nil\n\n\tcase SandboxTypeCube, SandboxTypeE2B, SandboxTypeDocker:\n\t\t// Session-scoped remote backends are only reachable through\n\t\t// SessionBoundManager, which owns the authoritative binding.\n\t\t// DefaultManager exposes stateless semantics that cannot preserve\n\t\t// per-session state, so we refuse the construction and let\n\t\t// NewManagerFromType route the caller to NewSessionBoundManager.\n\t\treturn fmt.Errorf(\n\t\t\t\"sandbox: %s backend must be constructed via NewSessionBoundManager\",\n\t\t\tm.config.Type,\n\t\t)\n\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown sandbox type: %s\", m.config.Type)\n\t}\n}\n\n// Execute runs a script using the configured sandbox\n// It performs security validation before execution to prevent prompt injection attacks\nfunc (m *DefaultManager) Execute(ctx context.Context, config *ExecuteConfig) (*ExecuteResult, error) {\n\tm.mu.RLock()\n\tsandbox := m.sandbox\n\tm.mu.RUnlock()\n\n\tif sandbox == nil {\n\t\treturn nil, ErrSandboxDisabled\n\t}\n\n\t// Check if sandbox is disabled - return early without validation\n\tif sandbox.Type() == SandboxTypeDisabled {\n\t\treturn nil, ErrSandboxDisabled\n\t}","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/sandbox/manager.go#L44-L80","documentation":"initializeSandbox's default branch handles any Config.Type that does not match a known sandbox type constant, returning \"unknown sandbox type: %s\". The library cannot instantiate a sandbox for an unrecognized backend identifier.","triggerScenarios":"Calling NewManager with a Config whose Type is set to a value that is not one of the defined SandboxType* constants (e.g. typo, empty string, or a type from an older version).","commonSituations":"Loading sandbox type from env/config strings without going through NewManagerFromType's normalization (which maps \"docker\", \"cube\", \"e2b\", \"disabled\", \"\"); renaming or removing sandbox types across library versions; tests constructing Config{Type: \"e2b\"} as a raw string instead of the constant.","solutions":["Set config.Type using the exported SandboxType* constants.","Parse user/env input with NewManagerFromType, which normalizes strings to constants.","Log/inspect the configured Type value and correct the misspelling.","Check the library version for renamed sandbox types and migrate."],"exampleFix":"// before\ncfg := DefaultConfig(); cfg.Type = \"E2B\" // wrong casing/string\n// after\ncfg := DefaultConfig(); cfg.Type = SandboxTypeE2B","handlingStrategy":"validation","validationCode":"switch cfg.Type {\ncase SandboxTypeLocal, SandboxTypeDisabled, SandboxTypeCube,\n     SandboxTypeE2B, SandboxTypeDocker:\n    // ok\ndefault:\n    return fmt.Errorf(\"unsupported sandbox type: %v\", cfg.Type)\n}","typeGuard":"func isKnownSandboxType(t SandboxType) bool {\n    switch t {\n    case SandboxTypeLocal, SandboxTypeDisabled,\n         SandboxTypeCube, SandboxTypeE2B, SandboxTypeDocker:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Always assign config.Type from exported SandboxType* constants","Normalize external strings via NewManagerFromType before constructing managers","Snapshot known types in tests to catch renames across versions"],"tags":["sandbox","configuration","unknown-type"],"backgroundTag":"invalid-enum-value","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}