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

chore: Update examples to use latest sdk changes #282

Merged
merged 3 commits into from
Jul 30, 2020

Conversation

lholmquist
Copy link
Contributor

@lholmquist lholmquist commented Jul 29, 2020

Signed-off-by: Lucas Holmquist lholmqui@redhat.com

Proposed Changes

  • This PR updates the examples to use the latest cloudevents module(3.x)

All the examples work except one curl statement in the express example that is being addressed by #284 and since we are using the ~ those changes will get picked up once a new patch version is released, automatically

Description

started the express example.  1 failure in the curl statement

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
@lholmquist
Copy link
Contributor Author

I noticed something with the express example. The last curl statement for v03 fails with an "Invalid Payload" error.

A Binary One with Base 64 Encoding

curl -X POST \
     -d'@../payload/data-1.txt' \
     -H'Content-Type:application/json' \
     -H'ce-specversion:0.3' \
     -H'ce-type:com.github.pull.create' \
     -H'ce-source:https://github.com/cloudevents/spec/pull/123' \
     -H'ce-id:45c83279-c8a1-4db6-a703-b3768db93887' \
     -H'ce-time:2019-06-21T17:31:00Z' \
     -H'ce-datacontentencoding:base64' \
     http://localhost:3000/

If you remove that ce-datacontentencoding header, it will work, but I don't think that is the right approach. The error is happening during this section of code: https://github.com/cloudevents/sdk-javascript/blob/master/src/event/spec.ts#L33, when testing if the data is Binary. but at this point, the data, at least in the example, is an object, so that check fails

@lance thoughts?

@lance
Copy link
Member

lance commented Jul 29, 2020

@lholmquist interesting... I've worked out what the problem is. See #284. I've got a fix, but need to add tests and check behavior with the structured receiver as well.

lance added a commit to lance/sdk-javascript that referenced this pull request Jul 29, 2020
The 0.3 specification states that `datacontentencoding` may be set to base64.
If an incoming event arrives over HTTP with this value set, and the content type
is either application/json or application/cloudevents+json, then ensure that
the data is decoded and parsed.

Fixes: cloudevents#284
See: cloudevents#282

Signed-off-by: Lance Ball <lball@redhat.com>
@lance
Copy link
Member

lance commented Jul 29, 2020

@lholmquist ok I have pushed a PR for a fix. I don't think that this deserves a quick version bump because it only affects encoded data on v0.3 events.

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
@lholmquist lholmquist marked this pull request as ready for review July 29, 2020 22:21
@lholmquist lholmquist changed the title squash: Start update of examples. chore: Update examples to use latest sdk changes Jul 29, 2020
lance added a commit that referenced this pull request Jul 30, 2020
The 0.3 specification states that `datacontentencoding` may be set to base64.
If an incoming event arrives over HTTP with this value set, and the content type
is either application/json or application/cloudevents+json, then ensure that
the data is decoded and parsed.

Fixes: #284
See: #282


Signed-off-by: Lance Ball <lball@redhat.com>
@lholmquist lholmquist merged commit 763838c into cloudevents:master Jul 30, 2020
@lholmquist lholmquist mentioned this pull request Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants