Skip to content
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

Fixing nil http.Result ack compare #559

Merged
merged 2 commits into from
Jul 28, 2020

Conversation

n3wscott
Copy link
Member

@n3wscott n3wscott commented Jul 27, 2020

fixes #558

I found two issues in the codebase:

  1. the client was using the old style !IsACK to understand if it should process the response into a CloudEvent. The thinking is if it was not an ACK, then there must not be any event to parse. This logic is incorrect, it should test for IsUndelivered. If the event never left, then it can't have a response.
  2. Nil http protocol Results are not treated as ACK.

Running the samples/http/responder and samples/http/requester now get the expected output:

2020/07/27 14:16:18 Event sent at 2020-07-27 14:16:18.236459 -0700 PDT m=+3.540167810
2020/07/27 14:16:18 Response status code 500
Response:
Validation: valid
Context Attributes,
  specversion: 1.0
  type: samples.http.mod7
  source: /mod7
  subject: https://github.com/cloudevents/sdk-go/v2/samples/requester#7
  id: 10a6563c-6400-4782-8654-39180bf8f080
  time: 2020-07-27T21:16:18.236026Z
  datacontenttype: application/json
Data,
  {
    "id": 7,
    "message": "mod 7 has issues!"
  }

Signed-off-by: Scott Nichols snichols@vmware.com

@n3wscott n3wscott force-pushed the events_on_errors branch 3 times, most recently from 420fdf8 to a520760 Compare July 27, 2020 21:24
Signed-off-by: Scott Nichols <snichols@vmware.com>
@n3wscott n3wscott requested a review from slinkydeveloper July 27, 2020 22:04
@slinkydeveloper slinkydeveloper added this to the SDK 2.2 milestone Jul 28, 2020
@slinkydeveloper slinkydeveloper added bug Something isn't working component/protocol/http labels Jul 28, 2020
Copy link
Member

@slinkydeveloper slinkydeveloper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a little change to the example, but lgtm

fmt.Printf("Got Response Data: %+v\n", data)
fmt.Printf("----------------------------\n")
} else {
// Parse result
var httpResult *cehttp.Result
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a little comment here?

If event is delivered then the result can be parsed as http result

And later

response could contain or not an event

Signed-off-by: Scott Nichols <snichols@vmware.com>
@n3wscott n3wscott merged commit 485e6f8 into cloudevents:master Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component/protocol/http
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parsing CloudEvent from HTTP response for 4xx,5xx status codes.
2 participants