From b897927cc7e973db257893f0fee55b1a8f1e0b48 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Tue, 12 Oct 2021 18:24:16 +0000 Subject: [PATCH] In logging batched requests, use slightly fewer quotes / escapes. (#5308) Fixes https://github.com/hashicorp/terraform-provider-google/issues/7628. Equally clear in the worst case, but less escaping most of the time. Signed-off-by: Modular Magician --- .changelog/5308.txt | 3 +++ google/batcher.go | 5 +++-- google/resource_iam_member.go | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 .changelog/5308.txt diff --git a/.changelog/5308.txt b/.changelog/5308.txt new file mode 100644 index 00000000000..f2fa5719827 --- /dev/null +++ b/.changelog/5308.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +iam: fixed request batching bug where failed requests would show unnecessary backslash escaping to the user. +``` diff --git a/google/batcher.go b/google/batcher.go index 3e701a07118..36aaccb16c4 100644 --- a/google/batcher.go +++ b/google/batcher.go @@ -3,10 +3,11 @@ package google import ( "context" "fmt" - "github.com/hashicorp/errwrap" "log" "sync" "time" + + "github.com/hashicorp/errwrap" ) const defaultBatchSendIntervalSec = 3 @@ -177,7 +178,7 @@ func (b *RequestBatcher) SendRequestWithTimeout(batchKey string, request *BatchR case resp := <-respCh: if resp.err != nil { return nil, errwrap.Wrapf( - fmt.Sprintf("Request %q returned error: {{err}}", request.DebugId), + fmt.Sprintf("Request `%s` returned error: {{err}}", request.DebugId), resp.err) } return resp.body, nil diff --git a/google/resource_iam_member.go b/google/resource_iam_member.go index 604c210d3b9..1c9ba8c9091 100644 --- a/google/resource_iam_member.go +++ b/google/resource_iam_member.go @@ -203,7 +203,7 @@ func resourceIamMemberCreate(newUpdaterFunc newResourceIamUpdaterFunc, enableBat } if enableBatching { err = BatchRequestModifyIamPolicy(updater, modifyF, config, - fmt.Sprintf("Create IAM Members %s %+v for %q", memberBind.Role, memberBind.Members[0], updater.DescribeResource())) + fmt.Sprintf("Create IAM Members %s %+v for %s", memberBind.Role, memberBind.Members[0], updater.DescribeResource())) } else { err = iamPolicyReadModifyWrite(updater, modifyF) }