-
Notifications
You must be signed in to change notification settings - Fork 70
Closed
Labels
type/bugSomething isn't workingSomething isn't working
Description
Describe the Bug
Doing a demo based on this blog to consume S3 events from Kamelet
The nodejs SDK can't handle the HTTP POST request with cloud event
Using the following code https://github.com/knative/docs/blob/main/docs/serving/samples/cloudevents/cloudevents-nodejs/index.js
Steps to Reproduce
- create nodejs service
- create trigger to send cloudevent from broker to nodejs service
Expected Behavior
That the cloud event is properly handle.
The knative event-display using the goland cloudevent can handle plaintext in body and missing content-type in header.
https://github.com/knative/eventing/blob/main/cmd/event_display/main.go#L59
Additional context
Try both versions of the SDK 4.0.3 and 5.0.0 same error
The input event from Camel Kamelet S3 is the following
Debug Incoming Request: {
"headers": {
"host": "func1.default.svc.cluster.local",
"user-agent": "Go-http-client/1.1",
"content-length": "11",
"accept-encoding": "gzip",
"ce-id": "A8A6BD24B2AE5FF-0000000000000017",
"ce-knativearrivaltime": "2021-11-17T22:48:50.315578709Z",
"ce-source": "source",
"ce-specversion": "1.0",
"ce-time": "2021-11-17T22:48:50.306Z",
"ce-type": "org.apache.camel.event",
"forwarded": "for=10.131.0.156;proto=http",
"k-proxy-request": "activator",
"traceparent": "00-0f3421c775056be4f762f87b5cee145d-5f24409ef4edc327-00",
"x-forwarded-for": "10.131.0.156, 10.128.2.48",
"x-forwarded-proto": "http",
"x-request-id": "13396d30-5487-46c1-9d21-b3fd675447e0"
},
"body": "test func1\n"
}
The error is the following
SyntaxError: Unexpected token
in JSON at position 11
at JSON.parse (<anonymous>)
at parseJSON (/opt/app-root/src/node_modules/cloudevents/dist/parsers.js:39:67)
at JSONParser.parse (/opt/app-root/src/node_modules/cloudevents/dist/parsers.js:40:16)
at parseBinary (/opt/app-root/src/node_modules/cloudevents/dist/message/http/index.js:166:23)
at Object.deserialize [as toEvent] (/opt/app-root/src/node_modules/cloudevents/dist/message/http/index.js:86:20)
at /opt/app-root/src/index.js:70:24
at Layer.handle [as handle_request] (/opt/app-root/src/node_modules/express/lib/router/layer.js:95:5)
at next (/opt/app-root/src/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/opt/app-root/src/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/opt/app-root/src/node_modules/express/lib/router/layer.js:95:5)
cc @lance
Metadata
Metadata
Assignees
Labels
type/bugSomething isn't workingSomething isn't working