From afdb57131933f5f5f9b6e9177fa9f0a31115e71f Mon Sep 17 00:00:00 2001 From: "Luis (LT) Carbonell" Date: Thu, 1 Dec 2022 13:36:24 -0600 Subject: [PATCH] Skip Formatting For NIL Secret (#18163) * Skip formatting for a nil secret data * Same change for put * Add changelog * update changelog * modify filtered output --- changelog/18163.txt | 3 +++ command/kv_patch.go | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 changelog/18163.txt diff --git a/changelog/18163.txt b/changelog/18163.txt new file mode 100644 index 000000000..f98c751bd --- /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 3d0f3456c..8313ec334 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")