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

CML comment create/update image links not working anymore in Gitlab #1478

Closed
jancrichter opened this issue Sep 27, 2024 · 1 comment · Fixed by #1482
Closed

CML comment create/update image links not working anymore in Gitlab #1478

jancrichter opened this issue Sep 27, 2024 · 1 comment · Fixed by #1482

Comments

@jancrichter
Copy link

jancrichter commented Sep 27, 2024

Hi everyone,

We are using Gitlab 17.4.1 and CML 0.20.4. We have recently started noticing that images added to MR comments via cml comment create or cml comment update, while uploaded correctly, cannot be accessed under the link CML puts into the MR comment.

CML puts in absolute URLs like

![](https://${myinstance}.gitlab.com/${mygroup}/${mysubgroup}/${myproject}/uploads/6aaacfcf584e185f78b6df984148ad6a/plot.png?cml=png&cache-bypass=b4c2a1c9-0d6b-41b4-975b-168e1d150e12 "plot_title")

For new file uploads in Gitlab 17 these URLs do not work anymore (they continue working for uploads that already exist).

What works instead is this:

![](https://${myinstance}.gitlab.com/-/projects/${myprojectsid}/uploads/6aaacfcf584e185f78b6df984148ad6a/plot.png?cml=png&cache-bypass=b4c2a1c9-0d6b-41b4-975b-168e1d150e12 "plot_title")

I was not able to find a change in Gitlab 17 that would explain this behaviour yet, so it might be configuration on our end. I talked to the admins but they aren't aware of anything either.

I would like to propose switching to a more robust version of the links though.
When users manually upload files to a comment, Gitlab simply puts in a relative path like this:

![](/uploads/6aaacfcf584e185f78b6df984148ad6a/plot.png?cml=png&cache-bypass=b4c2a1c9-0d6b-41b4-975b-168e1d150e12 "plot_title")

Is there any reason not to use this approach?

Update: Forgot to mention this above, but from what I saw from the CML code the currently used links are put together from the Gitlab API response of the projects/uploads endpoint and the project path. The former part being exactly that relative URL/path mentioned in my last code snippet. So, seemingly, all that would need to be done is to change

return { uri: `${repo}${url}`, mime, size };

and drop ${repo} from it. In my rather naive attempt of testing that it led to an assertion error for the URL though.

@shcheklein shcheklein added bug Something isn't working and removed bug Something isn't working labels Sep 27, 2024
@shcheklein
Copy link
Member

Is there any reason not to use this approach?

Seems reasonable. @skshetry do you have any information on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants