{"record":{"id":"9dd38e389819c450","repo":"Tencent/WeKnora","slug":"invalid-sandbox-config-w-9dd38e","errorCode":null,"errorMessage":"invalid sandbox config: %w","messagePattern":"invalid sandbox config: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sandbox/session_manager.go","lineNumber":128,"sourceCode":"\t// See NewSessionBoundManager.\n\tSkipHealthProbe bool\n}\n\n// NewSessionBoundManager wires the manager with an explicit RemoteSandboxClient\n// backend, binding store, and session existence checker. Every persistent\n// operation flows through these three dependencies; the manager never keeps\n// authoritative session→sandbox state locally.\n//\n// Provider identity comes from deps.Client.Provider() — not Config.Type —\n// so test harnesses and custom wiring that inject a different client backend\n// always project the correct template, TTL, and health timeout.\nfunc NewSessionBoundManager(deps SessionBoundManagerConfig) (*SessionBoundManager, error) {\n\tcfg := deps.Config\n\tif cfg == nil {\n\t\tcfg = DefaultConfig()\n\t}\n\tif err := ValidateConfig(cfg); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid sandbox config: %w\", err)\n\t}\n\tif deps.Client == nil {\n\t\treturn nil, errors.New(\"session bound manager requires a RemoteSandboxClient\")\n\t}\n\tif deps.Store == nil {\n\t\treturn nil, errors.New(\"session bound manager requires a SessionSandboxBindingStore\")\n\t}\n\tif deps.Checker == nil {\n\t\treturn nil, errors.New(\"session bound manager requires a SessionExistenceChecker\")\n\t}\n\n\tprovider := deps.Client.Provider()\n\tif !isRemoteProvider(provider) {\n\t\treturn nil, fmt.Errorf(\"sandbox: unsupported remote provider %q\", provider)\n\t}\n\n\t// Apply the provider's tuning defaults so downstream code reads only\n\t// non-zero TTL / timeout fields. Endpoint defaults are deliberately not","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/sandbox/session_manager.go#L110-L146","documentation":"NewSessionBoundManager validates the supplied (or default) Config before wiring dependencies. If ValidateConfig reports any invalid field — bad timeouts, negative TTLs, malformed endpoints, etc. — construction fails with 'invalid sandbox config' wrapping the specific validation error.","triggerScenarios":"Calling NewSessionBoundManager (directly or via NewManagerFromType / integration managers) with a Config containing invalid values: non-positive durations, invalid endpoint URLs, mutually inconsistent fields.","commonSituations":"Typo'd environment variable parsing (e.g. TTL as '0' or negative), hand-edited named configs missing required fields, upgrading to a version with stricter validation rules.","solutions":["Read the wrapped ValidateConfig error — it names the exact offending field","Fix the invalid Config field (ensure positive TTLs/timeouts and well-formed endpoints)","If no Config is needed, pass nil to use DefaultConfig()","Compare against DefaultConfig() to see expected field shapes"],"exampleFix":"// before\ncfg.Timeout = -5 * time.Second\nmgr, err := sandbox.NewSessionBoundManager(deps)\n// after\ncfg.Timeout = 30 * time.Second\nmgr, err := sandbox.NewSessionBoundManager(deps)","handlingStrategy":"validation","validationCode":"cfg := deps.Config\nif cfg == nil { cfg = sandbox.DefaultConfig() }\nif err := sandbox.ValidateConfig(cfg); err != nil {\n    return nil, fmt.Errorf(\"config rejected before construction: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"mgr, err := sandbox.NewSessionBoundManager(deps)\nif err != nil && strings.Contains(err.Error(), \"invalid sandbox config\") {\n    return nil, fmt.Errorf(\"fix sandbox config: %w\", err)\n}","preventionTips":["Validate config at startup before wiring managers","Parse durations/env vars with strict helpers that reject zero/negative values","Diff custom configs against DefaultConfig() when validation fails"],"tags":["go","configuration","validation"],"backgroundTag":"invalid-configuration","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}