{"record":{"id":"737041924912e30c","repo":"Tencent/WeKnora","slug":"remote-sandbox-upload-script-s-w","errorCode":null,"errorMessage":"remote sandbox: upload script %s: %w","messagePattern":"remote sandbox: upload script (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sandbox/remote_sandbox.go","lineNumber":150,"sourceCode":"\t\t\tTimeout: effectiveTimeout(cfg, 0),\n\t\t}\n\t\tstart := time.Now()\n\t\texecResult, err := s.client.Exec(ctx, handle, request)\n\t\treturn remoteExecuteResult(execResult, err, time.Since(start)), nil\n\t}\n\n\tcontent, err := readScriptContent(cfg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tscriptName := filepath.Base(cfg.Script)\n\tif scriptName == \"\" || scriptName == \".\" || scriptName == \"/\" {\n\t\treturn nil, ErrInvalidScript\n\t}\n\tremoteScript := path.Join(remoteScriptDir, scriptName)\n\n\tif err := s.client.WriteFile(ctx, handle, remoteScript, content); err != nil {\n\t\treturn nil, fmt.Errorf(\"remote sandbox: upload script %s: %w\", remoteScript, err)\n\t}\n\n\ttimeout := effectiveTimeout(cfg, 0)\n\trequest := RemoteExecRequest{\n\t\tCommand: getInterpreter(remoteScript),\n\t\tArgs:    append([]string{remoteScript}, cfg.Args...),\n\t\tStdin:   cfg.Stdin,\n\t\tEnv:     cfg.Env,\n\t\tWorkDir: remoteScriptDir,\n\t\tUser:    DefaultSandboxExecUser,\n\t\tTimeout: timeout,\n\t}\n\n\tstart := time.Now()\n\texecResult, err := s.client.Exec(ctx, handle, request)\n\tduration := time.Since(start)\n\treturn remoteExecuteResult(execResult, err, duration), nil\n}","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/sandbox/remote_sandbox.go#L132-L168","documentation":"ExecuteOnHandle uploads the script into the remote sandbox at a path under remoteScriptDir using client.WriteFile; if that upload fails the error is wrapped with the remote script path. The script never ran — this is purely an upload/transport failure against the sandbox handle.","triggerScenarios":"ExecuteOnHandle called with a script whose content WriteFile cannot persist: connection dropped mid-upload, payload too large, permissions on the remote path, or the handle was already disposed/expired.","commonSituations":"Long sessions where the remote sandbox was reaped mid-run; large skill scripts hitting size limits; flaky network between runner and sandbox; concurrent disposal of the same handle.","solutions":["Check the wrapped cause for connection vs permission vs size errors and address accordingly","Re-acquire a fresh handle (or re-create the sandbox) if the old one expired, then retry ExecuteOnHandle","Reduce script size or split the script if the upload hits payload limits","Avoid disposing handles concurrently while an ExecuteOnHandle is in flight"],"exampleFix":"// before\nres, err := sbx.ExecuteOnHandle(ctx, handle, cfg)\n// after\nres, err := sbx.ExecuteOnHandle(ctx, handle, cfg)\nif err != nil && strings.Contains(err.Error(), \"upload script\") {\n    if fresh, ferr := s.client.Create(ctx, s.createRequest); ferr == nil {\n        return sbx.ExecuteOnHandle(ctx, fresh, cfg)\n    }\n}","handlingStrategy":"fallback","validationCode":"if content, err := os.ReadFile(cfg.Script); err != nil || len(content) > maxUploadSize {\n    return fmt.Errorf(\"script unreadable or too large\")\n}","typeGuard":null,"tryCatchPattern":"res, err := sbx.ExecuteOnHandle(ctx, handle, cfg)\nif err != nil && strings.Contains(err.Error(), \"upload script\") {\n    return recreateHandleAndRetry(ctx, cfg)\n}","preventionTips":["Re-create handles rather than reusing long-lived ones","Keep scripts under provider upload size limits","Avoid concurrent disposal of a handle in use"],"tags":["go","sandbox","upload","network"],"backgroundTag":"file-upload-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}