tektoncd / triggers

Event triggering with Tekton!
Apache License 2.0
558 stars 420 forks source link

Failed replacing params from json event values #980

Closed c0ldd closed 3 years ago

c0ldd commented 3 years ago

Expected Behavior

EventListener should start TaskRun with param value from event body

Actual Behavior

EventListener failed to replacing params: {"level":"error","ts":"2021-03-04T13:45:28.858Z","logger":"eventlistener","caller":"sink/sink.go:230","msg":"failed to ApplyEventValuesToParams: failed to replace JSONPath value for param body: $(body.value): value is not found","knative.dev/controller":"eventlistener","/triggers-eventid":"hcpz2","/trigger":"test-event-trigger","logging.googleapis.com/labels":{},"logging.googleapis.com/sourceLocation":{"file":"github.com/tektoncd/triggers/pkg/sink/sink.go","line":"230","function":"github.com/tektoncd/triggers/pkg/sink.Sink.processTrigger"},"stacktrace":"github.com/tektoncd/triggers/pkg/sink.Sink.processTrigger\n\tgithub.com/tektoncd/triggers/pkg/sink/sink.go:230\ngithub.com/tektoncd/triggers/pkg/sink.Sink.HandleEvent.func1\n\tgithub.com/tektoncd/triggers/pkg/sink/sink.go:125"}

Steps to Reproduce the Problem

main_yml rbac kubectl port-forward svc/el-test-event-listener 8080:8080 curl -d '{"body":{"value":"Test value"}}' -H "Content-Type: application/json" -X POST http://localhost:8080/

Am i missing something ?

Additional Info

Client version: 0.15.0 Pipeline version: v0.21.0 Triggers version: v0.11.2 minikube version: v1.12.1

dibyom commented 3 years ago

Does it work with curl -d '{"value":"Test value"}' -H "Content-Type: application/json" -X POST http://localhost:8080/ or alternatively changing your TriggerBinding to use $(body.body.value)?

(The body key is implicitly added to refer to anything in the incoming request body. You could also do header.Content-Type for example)

c0ldd commented 3 years ago

Yep it's worked. So according to doc where example with "Keys with dots ." is example wrong ? It should be $(body.body.tekton\.dev) -> "triggers" to be workable ?