-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate EXTRA_VALUE_AT_END Key Appearing in Various Log Entries #30
Comments
With non-JSON output, we can see
|
This is due to errant log helper functions which accept |
…unctions to ...map[string]interface{} Reference: #30 Reference: #31 Previously, implementers could introduce mismatched key-value pairs or expect `f` suffix-like string formatting of the message due to the final `...interface{}` variadic argument. Updating this to `...map[string]interface{}` has the following benefits: - Calls that errantly were treating these as formatter functions will now receive a compiler error in the majority of cases (except parameters that already satisfied the `map[string]interface{}` type). - Matched pairing is now enforced via the compiler, preventing occurence of go-hclog's `EXTRA_VALUE_AT_END` key in entries. - Keys are now enforced to be `string`, where before they could be defined as other types and beholden to go-hclog's behavior of calling `fmt.Sprintf("%s", key)` resulting in likely unexpected keys for non-string types: ``` true: %!s(bool=true) 123: %!s(int=123) 123.456: %!s(float64=123.456) []string{"oops"}: [oops] MyCustomType (without String() method): {} ``` Some disadvantages of this new approach include: - Additional typing of the `map[string]T{}` for each call. Implementors can opt for `map[string]string` in many cases, or Go 1.18+ `map[string]any`, in preference over the potentially confusing/annoying `interface{}` typing. - The burden of converting existing calls. Pragmatically however, the advantages outweigh the disadvantages as this Go module does not yet have full compatibility promises (pre-1.0) and the direct dependencies are expected to grow exponentially in the near future when its existance is broadcasted more. Catching this critical API change earlier rather than later will have less of an effect on the ecosystem.
…unctions to ...map[string]interface{} (#34) Reference: #30 Reference: #31 Previously, implementers could introduce mismatched key-value pairs or expect `f` suffix-like string formatting of the message due to the final `...interface{}` variadic argument. Updating this to `...map[string]interface{}` has the following benefits: - Calls that errantly were treating these as formatter functions will now receive a compiler error in the majority of cases (except parameters that already satisfied the `map[string]interface{}` type). - Matched pairing is now enforced via the compiler, preventing occurence of go-hclog's `EXTRA_VALUE_AT_END` key in entries. - Keys are now enforced to be `string`, where before they could be defined as other types and beholden to go-hclog's behavior of calling `fmt.Sprintf("%s", key)` resulting in likely unexpected keys for non-string types: ``` true: %!s(bool=true) 123: %!s(int=123) 123.456: %!s(float64=123.456) []string{"oops"}: [oops] MyCustomType (without String() method): {} ``` Some disadvantages of this new approach include: - Additional typing of the `map[string]T{}` for each call. Implementors can opt for `map[string]string` in many cases, or Go 1.18+ `map[string]any`, in preference over the potentially confusing/annoying `interface{}` typing. - The burden of converting existing calls. Pragmatically however, the advantages outweigh the disadvantages as this Go module does not yet have full compatibility promises (pre-1.0) and the direct dependencies are expected to grow exponentially in the near future when its existance is broadcasted more. Catching this critical API change earlier rather than later will have less of an effect on the ecosystem.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
terraform-plugin-log version
Relevant provider source code
Noticed with
tfsdklog
usage of protocol logging, may also happen withtfsdk
usage.Expected Behavior
Log entries should not extraneously contain the
EXTRA_VALUE_AT_END
key, which is injected byhc-log
when it detects unpaired (key without value)With
usage, unless there is in fact an unpaired thing.Actual Behavior
Entries such as:
This could be caused by a bug in
hc-log
, a bug in this Go module, or buggy SDK/provider logger implementations. Let's rule out the first two. 😄Steps to Reproduce
TF_LOG_SDK_PROTO=trace terraform apply
from a provider using terraform-plugin-go@v0.7.0.The text was updated successfully, but these errors were encountered: