Page MenuHomePhabricator

Gerrit commit message formatting does not handle angle-bracketed URLs well, adds extra semicolon
Closed, ResolvedPublic

Description

Test case: https://gerrit.wikimedia.org/r/c/test/gerrit-ping/+/1043020


In this WikibaseLexeme Gerrit change, the commit message line

Pulls in <https://github.com/wmde/new-lexeme-special-page/pull/641>.

gets rendered as:

Pulls in <https://github.com/wmde/new-lexeme-special-page/pull/641>;.

Notice that the > became part of the link, and there’s also an extra ; for no apparent reason; angle brackets are supposed to be a way to mark the boundaries of a URL in Markdown-like text.

From duplicated T359878:

In this change: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1009851

The Gerrit interface shows this:

image.png (89×1 px, 21 KB)

he Zend hack is no longer needed, as this existed to support PHP 5.5
as per <https://3v4l.org/EU6Ro>;.

But in the actual commit, as seen e.g. at https://gerrit.wikimedia.org/g/mediawiki/core/+/6194cf19ce73a90bb3bedf01a9c97eb5fbc40d17, the text is written as:

The Zend hack is no longer needed, as this existed to support PHP 5.5
as per <https://3v4l.org/EU6Ro>.

Gerrit shows an extra ; that appears out of nowhere.

Event Timeline

I don’t know if this is anything specific in our config or an upstream issue – I figured I’d report it here first.

I’ve now pushed a new patch set that removes the angle brackets; unfortunately, Gerrit always shows the latest commit message even when looking at an older patch set, so that means you can’t easily reproduce this anymore :S

This is a upstream issue but testing on master it appears it's fixed.

I believe gerrit 3.8 may fix the problem. It got rid of a library that had problems. Although I can't guarantee as I've only tested on master.

Alright, thanks! Feel free to close this already then. (Or keep it open and link it to T354886, I guess?)

hashar subscribed.

Alright, thanks! Feel free to close this already then. (Or keep it open and link it to T354886, I guess?)

I keep the bug reports opens and mark them with a milestone associated with the version that fixes it, in this case #gerrit3.8: Gerrit (Gerrit 3.8). Then once upgraded, we can crawl through the milestone, verify all those have indeed been fixed and closed them as needed (else move them to the next milestone or back in the default Gerrit).

hashar claimed this task.

The issue has been fixed by upgrading to Gerrit 3.8 on Monday 15th :)

Indeed that was not fixed. The reason I have marked the task resolved was that the first link in this task points to https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikibaseLexeme/+/1007609/1 which does not show the issue and I thus assumed it to have been fixed but it does show https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1009851 which I guess is a variation.

Indeed that was not fixed. The reason I have marked the task resolved was that the first link in this task points to https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikibaseLexeme/+/1007609/1 which does not show the issue

Yeah, that’s because of:

I’ve now pushed a new patch set that removes the angle brackets; unfortunately, Gerrit always shows the latest commit message even when looking at an older patch set, so that means you can’t easily reproduce this anymore :S

We have upgraded to Gerrit 3.9.5 and this is still happening.

Change #1043020 had a related patch set uploaded (by Hashar; author: Hashar):

[test/gerrit-ping@master] Angle bracketed URL in commit message

https://gerrit.wikimedia.org/r/1043020

hashar updated the task description. (Show Details)

Fun thing I have noticed is the <a> element shallows the closing bracket and the href contains the closing bracket. So it is more complicated than just a ; being added. I think the link is generated by:

polygerrit-ui/app/utils/link-util.ts
function createLinkTemplate(
  href: string,
  displayText: string,
  prefix?: string,
  suffix?: string
) {
  return `${
    prefix ?? ''
  }<a href="${href}" rel="noopener noreferrer" target="_blank">${displayText}</a>${
    suffix ?? ''
  }`;
}

Which would be fed:

prefix<
hrefhttps://example.com>
displayTexthttps://example.com>
suffix;

The method is apparently called solely for processing commentlink which are regex feeding the above function. Maybe one of our configured comment link is the cause of the issue?

Fun thing I have noticed is the <a> element shallows the closing bracket and the href contains the closing bracket. So it is more complicated than just a ; being added. I think the link is generated by:

polygerrit-ui/app/utils/link-util.ts
function createLinkTemplate(
  href: string,
  displayText: string,
  prefix?: string,
  suffix?: string
) {
  return `${
    prefix ?? ''
  }<a href="${href}" rel="noopener noreferrer" target="_blank">${displayText}</a>${
    suffix ?? ''
  }`;
}

Which would be fed:

prefix<
hrefhttps://example.com>
displayTexthttps://example.com>
suffix;

The method is apparently called solely for processing commentlink which are regex feeding the above function. Maybe one of our configured comment link is the cause of the issue?

It works for me on master:

Screenshot 2024-06-13 at 13.19.47.png (552×1 px, 136 KB)

Change #1043020 abandoned by Hashar:

[test/gerrit-ping@master] Angle bracketed URL in commit message

Reason:

https://gerrit.wikimedia.org/r/1043020

Change #1043066 had a related patch set uploaded (by Hashar; author: Hashar):

[operations/software/gerrit@wmf/stable-3.9] Merge commit 'stable-3.9@7380128525' into wmf/stable-3.9

https://gerrit.wikimedia.org/r/1043066

Change #1043066 merged by jenkins-bot:

[operations/software/gerrit@wmf/stable-3.9] Merge commit 'stable-3.9@7380128525' into wmf/stable-3.9

https://gerrit.wikimedia.org/r/1043066

Change #1043084 had a related patch set uploaded (by Hashar; author: Hashar):

[operations/software/gerrit@deploy/wmf/stable-3.9] Update to a snapshot of Gerrit 3.9.6

https://gerrit.wikimedia.org/r/1043084

Change #1043084 merged by jenkins-bot:

[operations/software/gerrit@deploy/wmf/stable-3.9] Update to a snapshot of Gerrit 3.9.6

https://gerrit.wikimedia.org/r/1043084

Mentioned in SAL (#wikimedia-operations) [2024-06-13T14:32:11Z] <hashar@deploy1002> Started deploy [gerrit/gerrit@89042ad]: Gerrit to snapshot version 3.9.5-22-g7380128525 on gerrit2002 # T358762

Mentioned in SAL (#wikimedia-operations) [2024-06-13T14:32:18Z] <hashar@deploy1002> Finished deploy [gerrit/gerrit@89042ad]: Gerrit to snapshot version 3.9.5-22-g7380128525 on gerrit2002 # T358762 (duration: 00m 07s)

Mentioned in SAL (#wikimedia-operations) [2024-06-13T14:40:58Z] <hashar@deploy1002> Started deploy [gerrit/gerrit@89042ad]: Gerrit to snapshot version 3.9.5-22-g7380128525 on gerrit1003 # T358762

Mentioned in SAL (#wikimedia-operations) [2024-06-13T14:41:03Z] <hashar@deploy1002> Finished deploy [gerrit/gerrit@89042ad]: Gerrit to snapshot version 3.9.5-22-g7380128525 on gerrit1003 # T358762 (duration: 00m 05s)

That got fixed on the test case https://gerrit.wikimedia.org/r/c/test/gerrit-ping/+/1043020 . The fix was made during the 3.9 release candidate and got erroneously reverted. It will be released again in v3.9.6.

Huge thanks to @Paladox for the backporting/war building etc ;)

Change #1043020 restored by Hashar:

[test/gerrit-ping@master] Angle bracketed URL in commit message

https://gerrit.wikimedia.org/r/1043020

Change #1043020 abandoned by Hashar:

[test/gerrit-ping@master] Angle bracketed URL in commit message

Reason:

https://gerrit.wikimedia.org/r/1043020