On using multiple webhooks, when the first webhook...
# talk-kratos
e
On using multiple webhooks, when the first webhook is successful and gives a status 200, i get an error saying
Copy code
{
  "id": "b7593ca3-1bda-4ba2-93f6-c13490ed1a71",
  "error": {
    "code": 500,
    "status": "Internal Server Error",
    "message": "hook response could not be unmarshalled properly from JSON: invalid character 'S' looking for beginning of value"
  },
  "created_at": "2023-03-22T08:34:47.049429Z",
  "updated_at": "2023-03-22T08:34:47.049429Z"
}
my webhooks config
Copy code
registration:
      lifespan: 10m
      ui_url: <http://127.0.0.1:3000/registration>
      after:
        password:
          hooks:
            - hook: web_hook
              config:
                url: <http://host.docker.internal:4000/api/v1/web-hooks/ory-identities/check-user-in-invite>
                method: POST
                body: <base64://ZnVuY3Rpb24oY3R4KSB7CiBlbWFpbDogY3R4LmlkZW50aXR5LnRyYWl0cy5lbWF>pbCwKIGN0eDogY3R4Cn0=
                can_interrupt: true
            - hook: web_hook
              config:
                url: <http://host.docker.internal:4000/api/v1/web-hooks/ory-identities/generate-key-for-registered-user>
                method: POST
                body: <base64://ZnVuY3Rpb24oY3R4KSB7CiBlbWFpbDogY3R4LmlkZW50aXR5LnRyYWl0cy5lbWF>pbCwKIGN0eDogY3R4Cn0=
                can_interrupt: true
            - hook: session
this is how my api returns the error (ory reacts properly incase of error)
Copy code
return res.status(404).json({
      messages: [
        {
          instance_ptr: "#/traits/email",
          messages: [
            {
              id: 123,
              text: "Not found in waiting list",
              type: "validation",
              context: {
                value: "not allowed",
              },
            },
          ],
        },
      ],
    });
this is how i return success (ory is unable to handle even when status code is 200)
Copy code
return res.status(200).send("Success");
It appears that it is trying to parse the response even when status code is 200. I am using ory v0.11.0
p
"Success" isn't valid json. It would most likely need to be something like
Copy code
{
  "message": "success"
}
On the latest commit of Kratos there is support for
config.response.parse: false
https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks#modify-identities
e
tried this doesn't work
p
Are you using the latest commit from master?
This has been merged already to master, but not released
e
the thing is it shouldn't interrupt the flow if the request gives 200 status. but it still does
not using master, using v0.11.0 with docker
is it fixed in next release?
p
the thing is it shouldn't interrupt the flow if the request gives 200 status. but it still does
Yes because the json marshalling is failing. This isn't returning valid json:
Copy code
return res.status(200).send("Success");
Instead it should be:
Copy code
return res.status(200).send({"message":"success"});
e
okay
p
is it fixed in next release?
Nothing needs to be fixed if valid json is returned. But if you want to prevent the webhook from parsing the response then you need the latest commit from master
e
understood
when is the next stable release?
p
We do releases each quarter https://www.ory.sh/docs/open-source/commitment#binary-and-docker-releases But can't say exactly when we will do so
e
got it
136 Views