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

Parsing JSON strings in CEL interceptors #538

Closed
jace-ys opened this issue Apr 15, 2020 · 5 comments
Closed

Parsing JSON strings in CEL interceptors #538

jace-ys opened this issue Apr 15, 2020 · 5 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@jace-ys
Copy link

jace-ys commented Apr 15, 2020

Expected Behavior

It will be really useful if we could parse JSON strings in CEL interceptors, when we get a payload containing a JSON string field.

Actual Behavior

When my EventListener receives deployment webhooks from GitHub, that JSON object contains a payload field that's a JSON string (not sure why GitHub does this 😓). Example:

{
  "action": "created",
  "deployment": {
    "url": "https://api.github.com/repos/Codertocat/Hello-World/deployments/145988746",
    "id": 145988746,
    "node_id": "MDEwOkRlcGxveW1lbnQxNDU5ODg3NDY=",
    "sha": "f95f852bd8fca8fcc58a9a2d6c842781e32a215e",
    "ref": "master",
    "task": "deploy",
    "payload": "{\"hello\": \"world\"}", # this JSON string
    "original_environment": "production",
    "environment": "production",
    ...
  }
}

I would ideally like to do something like this in my interceptor body.deployment.payload.hello == 'world' , but since payload isn't treated as an object, I have to do body.deployment.payload == '{"hello": "world"}' which isn't great once i have a larger payload field.

Steps to Reproduce the Problem

  1. Send the above webhook payload to an EventListener containing a field with a JSON string
  2. Parse the body.deployment.payload.hello == 'world'
  3. EventListener doesn't evaluate the above statement to true

Additional Info

@dibyom
Copy link
Member

dibyom commented Apr 15, 2020

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Apr 15, 2020
@dibyom
Copy link
Member

dibyom commented Apr 27, 2020

Fixed in #537

@dibyom
Copy link
Member

dibyom commented Apr 27, 2020

/milestone 0.5

@dibyom
Copy link
Member

dibyom commented Apr 27, 2020

/close

@tekton-robot
Copy link

@dibyom: Closing this issue.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@dibyom dibyom added this to the Triggers v0.5.0 milestone Apr 27, 2020
nikhil-thomas pushed a commit to nikhil-thomas/triggers that referenced this issue Sep 17, 2021
Replace Registry using ENV provided by OpenShift CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

3 participants