Webhook issue description contains invalid URL for uploaded images content, producing broken image when supplied as description via RESTful API

Summary

Webhooks for issue have invalid '/uploads/' links within description

Steps to reproduce

  1. Configure your project so that webhooks regarding issues are delivered to your endpoint.
  2. Create the ability to log the delivered webhook messages
  3. Create an issue having a description that includes an image that you add to the issue
  4. Modify the issue description in some inconsequential way
  5. Observe the webhook messages that arrive, paying particular notice to the object_attributes.description value, as well as the changes.description.previous and changes.description.current values.

You should observe that:

a) the object_attributes.description contains a URL for the image that was uploaded which is fully qualified. You should find that the initial portion of this URL starts with the same value as that of the project.homepage, but, you should also find that if you copy the URL and paste it into a browser, you receive a message indicating the resource being requested does not exist.

b) observe that the changes.description.[current|previous] values do not contain fully qualified URLs, but only relative URLs.

c) Taking the relative URL and prefixing with https://gitlab.com/-/projects/{projectID}{relative URL to image} results in a perfectly findable resource.

d) Using the supplied object_attributes.description in a restful API request that updates the description by adding additional content results in the URL to the image now showing the 'broken image' icon graphic instead of the image.

Example Project

https://gitlab.com/te4360/demo-bad-webhook-issue-description-link-url

https://gitlab.com/te4360/demo-bad-webhook-issue-description-link-url/-/issues/1

What is the current bug behavior?

It behaves as described above. Visually, the link to the image within the description is broken.

If you set up to receive webhook, you will see that the object_attributes.description contains a fully qualified URL pointing to:

https://gitlab.com/te4360/demo-bad-webhook-issue-description-link-url/uploads/810c0e0f4e675a02bc05bce1c2508151/New_Issue___TestingGroup__Demo_bad_webhook_issue_description_link_URL___Git_2024-07-10_at_2.28.09_PM.png, which is not valid when used in a browser.

Additionally, if you send back this description (containing the bad fully qualified URL) via RESTful API that sets the issue description, the result will be that instead of showing the image, a 'broken image' icon is shown instead.

What is the expected correct behavior?

NOT the broken URL, but instead, either a properly formed fully qualified URL, or, just the relative URL.

Relevant logs and/or screenshots

The URL contained in object_attributes.description should either just be the relative URL, or, the fully qualified but correct URL.

I have observed that if I pass in a description value containing a fully qualified URL that is valid (ie: prefixed with https://gitlab.com/-/project/{project ID} that the prefix is removed from what is subsequently returned, and the image appears correctly in the GitLab web page when viewing the issue.

object_attributes: {
     author_id: 3494303,
     closed_at: null,
     confidential: false,
     created_at: '2024-07-10T19:28:38.637Z',
     description: 'Here is an image:\n' +
       '\n' +
       '![New_Issue___TestingGroup__Demo_bad_webhook_issue_description_link_URL___Git_2024-07-10_at_2.28.09_PM](https://gitlab.com/te4360/demo-bad-webhook-issue-description-link-url/uploads/810c0e0f4e675a02bc05bce1c2508151/New_Issue___TestingGroup__Demo_bad_webhook_issue_description_link_URL___Git_2024-07-10_at_2.28.09_PM.png)',
     discussion_locked: null,

Opening in a browser: https://gitlab.com/te4360/demo-bad-webhook-issue-description-link-url/uploads/810c0e0f4e675a02bc05bce1c2508151/New_Issue___TestingGroup__Demo_bad_webhook_issue_description_link_URL___Git_2024-07-10_at_2.28.09_PM.png provides an HTTP 404 error.

However, using: https://gitlab.com/-/project/59783545/uploads/810c0e0f4e675a02bc05bce1c2508151/New_Issue___TestingGroup__Demo_bad_webhook_issue_description_link_URL___Git_2024-07-10_at_2.28.09_PM.png produces the expected image.

Output of checks

This bug happens on GitLab.com

Possible fixes

As mentioned, either provide just the relative URL in the object_attributes.description, or, a fully qualified but correct URL prefix ahead of the /uploads/

Edited by Peter Belbin