diff --git a/changelog/18163.txt b/changelog/18163.txt new file mode 100644 index 000000000000..f98c751bdd68 --- /dev/null +++ b/changelog/18163.txt @@ -0,0 +1,3 @@ +```release-note:bug +cli/kv: skip formatting of nil secrets for patch and put with field parameter set +``` \ No newline at end of file diff --git a/command/kv_patch.go b/command/kv_patch.go index 3d0f3456c2b3..8313ec33487c 100644 --- a/command/kv_patch.go +++ b/command/kv_patch.go @@ -252,6 +252,14 @@ func (c *KVPatchCommand) Run(args []string) int { if code != 0 { return code } + if secret == nil { + // Don't output anything if there's no secret + return 0 + } + + if c.flagField != "" { + return PrintRawField(c.UI, secret, c.flagField) + } if Format(c.UI) == "table" { outputPath(c.UI, fullPath, "Secret Path")