{"record":{"id":"d6c00073cb5dc224","repo":"Tencent/WeKnora","slug":"invalid-sandbox-config-w","errorCode":null,"errorMessage":"invalid sandbox config: %w","messagePattern":"invalid sandbox config: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sandbox/manager.go","lineNumber":27,"sourceCode":")\n\n// DefaultManager implements the Manager interface\n// It handles sandbox selection and fallback logic\ntype DefaultManager struct {\n\tconfig    *Config\n\tsandbox   Sandbox\n\tvalidator *ScriptValidator\n\tmu        sync.RWMutex\n}\n\n// NewManager creates a new sandbox manager with the given configuration\nfunc NewManager(config *Config) (Manager, error) {\n\tif config == nil {\n\t\tconfig = DefaultConfig()\n\t}\n\n\tif err := ValidateConfig(config); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid sandbox config: %w\", err)\n\t}\n\n\tmanager := &DefaultManager{\n\t\tconfig:    config,\n\t\tvalidator: NewScriptValidator(),\n\t}\n\n\t// Initialize the appropriate sandbox\n\tif err := manager.initializeSandbox(context.Background()); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn manager, nil\n}\n\n// initializeSandbox creates and configures the sandbox based on configuration\nfunc (m *DefaultManager) initializeSandbox(ctx context.Context) error {\n\tswitch m.config.Type {","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/sandbox/manager.go#L9-L45","documentation":"NewManager builds the default sandbox manager. Before constructing it, the supplied Config is run through ValidateConfig; any validation failure is wrapped as \"invalid sandbox config: %w\" and manager creation fails. A nil config is tolerated (DefaultConfig is substituted), so the error always comes from field-level validation.","triggerScenarios":"Calling NewManager with a *Config whose fields fail ValidateConfig — e.g. an empty/unknown Type, an invalid DockerImage, or other constraint violations defined by ValidateConfig.","commonSituations":"Hand-assembling a Config struct instead of using DefaultConfig/NewManagerFromType; loading config from YAML/JSON where the sandbox type string is missing or misspelled; downstream callers constructing NewManager for remote backends with incomplete options.","solutions":["Start from DefaultConfig() and override only the fields you need.","Call ValidateConfig yourself before NewManager to see the exact failing field.","Use NewManagerFromType(sandboxType, ...) instead of constructing Config manually.","Fix the reported field (commonly config.Type) to a supported value."],"exampleFix":"// before\ncfg := &Config{} // Type unset\nmgr, err := NewManager(cfg)\n// after\ncfg := DefaultConfig()\ncfg.Type = SandboxTypeLocal\nmgr, err := NewManager(cfg)","handlingStrategy":"validation","validationCode":"if err := ValidateConfig(cfg); err != nil {\n    return fmt.Errorf(\"config rejected before NewManager: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"mgr, err := NewManager(cfg)\nif err != nil {\n    return fmt.Errorf(\"sandbox manager init failed: %w\", err)\n}","preventionTips":["Build configs from DefaultConfig() instead of zero-value structs","Run ValidateConfig as a startup health check","Prefer NewManagerFromType over hand-assembled Config"],"tags":["configuration","validation","sandbox"],"backgroundTag":"schema-validation-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}