{"record":{"id":"fe382f7ee681d500","repo":"wavetermdev/waveterm","slug":"setting-secret-w","errorCode":null,"errorMessage":"setting secret: %w","messagePattern":"setting secret: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-secret.go","lineNumber":131,"sourceCode":"\tvalue := parts[1]\n\n\tif name == \"\" {\n\t\treturn fmt.Errorf(\"secret name cannot be empty\")\n\t}\n\n\tbackend, err := wshclient.GetSecretsLinuxStorageBackendCommand(RpcClient, &wshrpc.RpcOpts{Timeout: 2000})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"checking secret storage backend: %w\", err)\n\t}\n\n\tif backend == \"basic_text\" || backend == \"unknown\" {\n\t\treturn fmt.Errorf(\"No appropriate secret manager found, cannot set secrets\")\n\t}\n\n\tsecrets := map[string]*string{name: &value}\n\terr = wshclient.SetSecretsCommand(RpcClient, secrets, &wshrpc.RpcOpts{Timeout: 2000})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"setting secret: %w\", err)\n\t}\n\n\tWriteStdout(\"secret set: %s\\n\", name)\n\treturn nil\n}\n\nfunc secretListRun(cmd *cobra.Command, args []string) (rtnErr error) {\n\tdefer func() {\n\t\tsendActivity(\"secret\", rtnErr == nil)\n\t}()\n\n\tnames, err := wshclient.GetSecretsNamesCommand(RpcClient, &wshrpc.RpcOpts{Timeout: 2000})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"listing secrets: %w\", err)\n\t}\n\n\tfor _, name := range names {\n\t\tWriteStdout(\"%s\\n\", name)","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-secret.go#L113-L149","documentation":"This wraps any failure of the SetSecretsCommand RPC (2s timeout) that actually persists the secret after all local validation and backend checks passed. The daemon-side write into the secret manager failed — or the RPC could not complete at all — so the secret was not stored (or not confirmed stored).","triggerScenarios":"Running `wsh secret set NAME=VALUE` when the daemon is unreachable or the RPC times out (2000ms), when the OS keyring rejects or errors on the write (locked keyring, D-Bus failure, storage quota), or when the server rejects the name server-side despite client validation (version mismatch).","commonSituations":"Keyring locked after screen-lock/session timeout so writes fail; secret-service crashes mid-write; Wave daemon restarted between the backend check and the set; very slow keyring making the 2s timeout too tight; older daemon rejecting newer name rules.","solutions":["Read the wrapped inner error: if it is a timeout, retry once after confirming the daemon is responsive (`wsh ls`).","Unlock/restart your OS keyring (gnome-keyring/kwallet) and ensure the user session's secret service is running, then retry the set.","Restart Wave Terminal to re-establish the RPC connection, then re-run the command.","Verify the secret was not partially written with `wsh secret get NAME` / `wsh secret list` and re-set it; update Wave/wsh to matching versions if server-side validation rejects the name."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight: confirm daemon reachable and keyring writable\n// if err := exec.Command(\"wsh\", \"ls\").Run(); err != nil { /* reconnect first */ }","typeGuard":null,"tryCatchPattern":"err := wshclient.SetSecretsCommand(RpcClient, secrets, &wshrpc.RpcOpts{Timeout: 2000})\nif err != nil {\n    if errors.Is(err, ErrTimeout) {\n        // retry once after confirming the daemon responds\n    }\n    return fmt.Errorf(\"setting secret: %w\", err)\n}","preventionTips":["Keep the OS keyring unlocked during automated secret writes","Verify success with `wsh secret get NAME` after setting in scripts","Retry transient RPC timeouts once before failing the pipeline","Restart Wave if the daemon connection is stale (other wsh commands failing too)"],"tags":["rpc","secrets","keyring","timeout"],"backgroundTag":"rpc-call-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}