Skip to content

Error serializing payload with backslash in a field in a custom webhook template

Summary

When using a custom webhook template, if the contents of one of the fields contains a backslash (\), the webhook fails with the error:

Internal error occurred while delivering this webhook.
Error: Error while parsing rendered custom webhook template: unexpected character 

This was encountered using the {{changes.description.current}} field, where the description of a merge request contains escaped markdown special characters, for example \[test], but was reproduced with a description with only a \ character (link below).

This does not occur if a custom template is not used.

Steps to reproduce

  1. Create a webhook with a custom webhook template, for example `{"description": "{{changes.description.current}}" }" that triggers on merge request events (or others).
  2. Create a merge request with a \ in the description.
  3. Webhook fails

Example Project

This merge requests creates the error gitlab-ci-utils/tests/renovate-webhook-test!6 (closed).

image

What is the current bug behavior?

Webhook fails to properly serialize the payload.

What is the expected correct behavior?

Webhook should properly escape all field in the payload.

Output of checks

This bug happens on GitLab.com

Edited by 🤖 GitLab Bot 🤖