{"record":{"id":"ddded174a8ffedae","repo":"kovidgoyal/kitty","slug":"failed-to-upload-s-w","errorCode":null,"errorMessage":"failed to upload %s: %w","messagePattern":"failed to upload (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/remote_file/actions.go","lineNumber":188,"sourceCode":"\t// Mirrors main.py handle_action's edit branch: reset the terminal (clear\n\t// whatever the ask-menu/hostname-prompt phases drew) right before handing\n\t// the screen to the user's $EDITOR, and again once it exits.\n\treset_terminal()\n\targv := append(append([]string{}, editor...), master.Dest)\n\tcmd := exec.Command(argv[0], argv[1:]...)\n\tcmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr\n\tif err := cmd.Start(); err != nil {\n\t\treturn err\n\t}\n\tdone := make(chan error, 1)\n\tgo func() { done <- cmd.Wait() }()\n\tfor {\n\t\tselect {\n\t\tcase <-done:\n\t\t\treset_terminal()\n\t\t\tif master.IsAlive() {\n\t\t\t\tif err := master.Upload(false); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to upload %s: %w\", master.remote_path, err)\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"failed to upload %s, SSH master process died\", master.remote_path)\n\t\tcase <-time.After(100 * time.Millisecond):\n\t\t\tif st, err := os.Stat(master.Dest); err == nil && st.ModTime().After(mtime) {\n\t\t\t\tmtime = st.ModTime()\n\t\t\t\tif master.IsAlive() {\n\t\t\t\t\t_ = master.Upload(true)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","sourceCodeStart":170,"sourceCodeEnd":203,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/remote_file/actions.go#L170-L203","documentation":"In the remote_file edit loop, once the local editor signals done, the file is re-uploaded over the SSH ControlMaster. This error means Upload() returned an error (the underlying scp/ssh copy failed) while the master process was still alive; the remote path is included.","triggerScenarios":"Calling handle_action for an edit where the remote host rejects the copy (permissions changed, disk full, remote path removed) even though the ssh master is up.","commonSituations":"Remote file deleted or permissions changed while editing, remote filesystem full, or transient network degradation causing the multiplexed copy to fail.","solutions":["Check the wrapped error for the underlying scp/ssh failure reason","Verify the remote path still exists and is writable","Retry the edit/upload; if persistent, re-establish the ControlMaster","Ensure remote disk space and permissions are adequate"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := handle_action(...); err != nil && strings.Contains(err.Error(), \"failed to upload\") {\n    // re-check remote writability, re-establish master, retry upload\n}","preventionTips":["Verify remote path writability before editing","Keep the ControlMaster alive during sessions","Retry uploads on transient network errors"],"tags":["ssh","scp","upload","remote-file"],"backgroundTag":"file-upload-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}