{"record":{"id":"03ab8b6277373307","repo":"wavetermdev/waveterm","slug":"deleting-secret-w","errorCode":null,"errorMessage":"deleting secret: %w","messagePattern":"deleting secret: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-secret.go","lineNumber":167,"sourceCode":"\t\tWriteStdout(\"%s\\n\", name)\n\t}\n\treturn nil\n}\n\nfunc secretDeleteRun(cmd *cobra.Command, args []string) (rtnErr error) {\n\tdefer func() {\n\t\tsendActivity(\"secret\", rtnErr == nil)\n\t}()\n\n\tname := args[0]\n\tif !secretNameRegex.MatchString(name) {\n\t\treturn fmt.Errorf(\"invalid secret name: must start with a letter and contain only letters, numbers, and underscores\")\n\t}\n\n\tsecrets := map[string]*string{name: nil}\n\terr := wshclient.SetSecretsCommand(RpcClient, secrets, &wshrpc.RpcOpts{Timeout: 2000})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"deleting secret: %w\", err)\n\t}\n\n\tWriteStdout(\"secret deleted: %s\\n\", name)\n\treturn nil\n}\n\nfunc secretUiRun(cmd *cobra.Command, args []string) (rtnErr error) {\n\tdefer func() {\n\t\tsendActivity(\"secret\", rtnErr == nil)\n\t}()\n\n\ttabId := getTabIdFromEnv()\n\tif tabId == \"\" {\n\t\treturn fmt.Errorf(\"no WAVETERM_TABID env var set\")\n\t}\n\n\twshCmd := &wshrpc.CommandCreateBlockData{\n\t\tTabId: tabId,","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-secret.go#L149-L185","documentation":"wsh secret delete works by calling SetSecretsCommand with the secret name mapped to nil, which clears it server-side. When that RPC fails for any reason (timeout, no connection to the Wave block, server error), the CLI wraps the failure as \"deleting secret: %w\". It is a pass-through wrapper: the underlying cause is what matters.","triggerScenarios":"Running `wsh secret delete <name>` when the SetSecretsCommand RPC fails: not attached to a running Wave terminal block, RPC exceeds the 2000ms timeout, or the wave server rejects the delete (e.g. the secret name no longer exists or internal storage error).","commonSituations":"Running the command from a plain shell outside the terminal so the RPC cannot route; Wave is busy/frozen so the 2s timeout fires; typo of a nonexistent secret on backends that reject unknown keys.","solutions":["Run the command from inside a Wave terminal block (check WAVETERM_TABID/WAVETERM_BLOCKID env vars are set) so the RPC reaches the app.","Check that Wave Terminal is running and responsive; retry if the 2s RPC timed out under load.","Verify the secret name with `wsh secret ls` (or equivalent) and retry with the exact name."],"exampleFix":"// before\nerr := wshclient.SetSecretsCommand(RpcClient, secrets, &wshrpc.RpcOpts{Timeout: 2000})\n// after\nerr := wshclient.SetSecretsCommand(RpcClient, secrets, &wshrpc.RpcOpts{Timeout: 2000})\nif err != nil {\n    return fmt.Errorf(\"deleting secret (is wsh attached to a running Wave block?): %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"if os.Getenv(\"WAVETERM_BLOCKID\") == \"\" { return errors.New(\"must run inside a Wave terminal block\") }\nif name == \"\" || !regexp.MustCompile(`^[A-Za-z][A-Za-z0-9_]*$`).MatchString(name) { return errors.New(\"invalid secret name\") }","typeGuard":"func validSecretName(name string) bool { re := regexp.MustCompile(`^[A-Za-z][A-Za-z0-9_]*$`); return re.MatchString(name) }","tryCatchPattern":"if err := wshclient.SetSecretsCommand(RpcClient, secrets, &wshrpc.RpcOpts{Timeout: 2000}); err != nil {\n    if errors.Is(err, context.DeadlineExceeded) { /* retry once */ }\n    return fmt.Errorf(\"deleting secret: %w\", err)\n}","preventionTips":["Only run secret commands from inside a Wave terminal block.","Validate the secret name format before calling the RPC.","Increase the RPC timeout if Wave is under heavy load."],"tags":["cli","rpc","secrets","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"}