{"record":{"id":"acd1ddb716986924","repo":"wavetermdev/waveterm","slug":"canceled-by-the-user","errorCode":null,"errorMessage":"canceled by the user","messagePattern":"canceled by the user","errorType":"error_code","errorClass":"UserInputCancelError","httpStatus":null,"severity":"info","filePath":"pkg/remote/sshclient.go","lineNumber":506,"sourceCode":"\terr := os.MkdirAll(path, 0700)\n\tif err != nil {\n\t\treturn err\n\t}\n\tf, err := os.OpenFile(knownHostsFile, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// do not close writeable files with defer\n\n\t// this file works, so let's ask the user for permission\n\tresponse, err := getUserVerification()\n\tif err != nil {\n\t\tf.Close()\n\t\treturn UserInputCancelError{Err: err}\n\t}\n\tif !response.Confirm {\n\t\tf.Close()\n\t\treturn UserInputCancelError{Err: fmt.Errorf(\"canceled by the user\")}\n\t}\n\n\t_, err = f.WriteString(newLine + \"\\n\")\n\tif err != nil {\n\t\tf.Close()\n\t\treturn err\n\t}\n\treturn f.Close()\n}\n\nfunc createUnknownKeyVerifier(ctx context.Context, knownHostsFile string, hostname string, remote string, key ssh.PublicKey) func() (*userinput.UserInputResponse, error) {\n\tbase64Key := base64.StdEncoding.EncodeToString(key.Marshal())\n\tqueryText := fmt.Sprintf(\n\t\t\"The authenticity of host '%s (%s)' can't be established \"+\n\t\t\t\"as it **does not exist in any checked known_hosts files**. \"+\n\t\t\t\"The host you are attempting to connect to provides this %s key:  \\n\"+\n\t\t\t\"%s.\\n\\n\"+\n\t\t\t\"**Would you like to continue connecting?** If so, the key will be permanently \"+","sourceCodeStart":488,"sourceCodeEnd":524,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/remote/sshclient.go#L488-L524","documentation":"writeToKnownHosts is called to persist a new host key into the known_hosts file after the user is asked to confirm. This error is a UserInputCancelError returned when the user explicitly declines the confirmation (response.Confirm == false). Declining is treated as a cancel of the connection rather than a generic failure, and the known_hosts file is left unmodified (file is closed without writing).","triggerScenarios":"Connecting to a host whose key is not in any known_hosts file (unknown host verifier path) and clicking 'No' / rejecting the 'Would you like to continue connecting?' prompt.","commonSituations":"First-time connection to a new server where the user is unsure; automated/headless environments where the prompt times out or a UI returns Confirm=false by default; security-conscious users refusing to trust an unfamiliar key.","solutions":["Reconnect and accept the host-key confirmation prompt (choose Yes).","Pre-populate known_hosts with the host's key (ssh-keyscan host >> known_hosts) to skip the prompt.","For automation, ensure the user-input provider returns Confirm=true or pre-trust the key out of band."],"exampleFix":"// before (manual)\n$ ssh-keyscan myhost\n// after\n$ ssh-keyscan myhost >> ~/.ssh/known_hosts  # pre-trust so the confirm prompt isn't declined","handlingStrategy":"try-catch","validationCode":"// pre-trust the host key so no confirmation prompt is needed\nexec.Command(\"ssh-keyscan\", \"-H\", hostname).Run() // append output to known_hosts","typeGuard":null,"tryCatchPattern":"err := Connect(...)\nvar uice UserInputCancelError\nif errors.As(err, &uice) && strings.Contains(err.Error(), \"canceled by the user\") {\n    // user declined host key trust; surface a friendly message or retry\n}","preventionTips":["Pre-populate known_hosts with ssh-keyscan for known infrastructure.","Educate users that accepting adds the key to known_hosts (MITM protection).","For headless runs, seed known_hosts before unattended connections."],"tags":["ssh","known-hosts","user-cancelled"],"backgroundTag":"host-key-verification-declined","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}