Skip to content
This repository has been archived by the owner on Jun 19, 2022. It is now read-only.

Fix wrong status message by changing %w to %v. #1675

Merged
merged 1 commit into from
Sep 9, 2020

Conversation

zhongduo
Copy link
Contributor

@zhongduo zhongduo commented Sep 9, 2020

Experiment shows that %w does not invoke the Error() string method
that the error type provides for proper struct formatting. When using
it in status message or logger, we will get sth like:

- lastTransitionTime: "2020-09-09T13:23:24Z"
    message: 'Failed to verify Pub/Sub topic exists: %!w(*status.Error=&{0xc0024ffe60})'
    reason: TopicVerificationFailed

After the fix, it will show as:

- lastTransitionTime: "2020-09-09T14:13:41Z"
    message: |-
      Failed to verify Pub/Sub topic exists: rpc error: code = Unauthenticated desc = transport: oauth2: cannot fetch token: 400 Bad Request
      Response: {"error":"invalid_grant","error_description":"Invalid JWT Signature."}
    reason: TopicVerificationFailed

Fixes #1672

Proposed Changes

  • Replace %w with %v in status message and logging

Release Note

- 🐛 Fix bug status messag showing error

Docs

Experiment shows that `%w` does not invoke the `Error() string` method
that the error type provides for proper struct formatting. When using
it in status message or logger, we will get sth like:
```
- lastTransitionTime: "2020-09-09T13:23:24Z"
    message: 'Failed to verify Pub/Sub topic exists: %!w(*status.Error=&{0xc0024ffe60})'
    reason: TopicVerificationFailed
```

After the fix, it will show as:

```
- lastTransitionTime: "2020-09-09T14:13:41Z"
    message: |-
      Failed to verify Pub/Sub topic exists: rpc error: code = Unauthenticated desc = transport: oauth2: cannot fetch token: 400 Bad Request
      Response: {"error":"invalid_grant","error_description":"Invalid JWT Signature."}
    reason: TopicVerificationFailed
```
@google-cla google-cla bot added the cla: yes (override cla status due to multiple authors bug) label Sep 9, 2020
@grac3gao-zz
Copy link
Contributor

/lgtm
/approve

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: grac3gao, zhongduo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-test-reporter-robot

The following jobs failed:

Test name Triggers Retries
pull-google-knative-gcp-wi-tests 2020-09-09 19:50:12.519 +0000 UTC
2020-09-09 20:35:12.567 +0000 UTC
2/3

Automatically retrying due to test flakiness...
/test pull-google-knative-gcp-wi-tests

@knative-prow-robot knative-prow-robot merged commit 3ed2eff into google:master Sep 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved cla: yes (override cla status due to multiple authors bug) lgtm size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong error message when failed to verify Pub/Sub topic exists
4 participants