Mattermost slash integration uses relative url for author_icon

Summary

Mattermost slash integration uses a relative url for author_icon. When Mattermost and GitLab are on different hosts, this causes the the author icon in Mattermost to be a broken image.

Steps to reproduce

  • Run Mattermost outside of GitLab Omnibus.
  • Enable Mattermost slash commands for a project
  • Use any slash command

What is the current bug behavior?

The author_icon is a relative path.

What is the expected correct behavior?

The author_icon should be an absolute URL.

Relevant logs and/or screenshots

{
  "response_type": "in_channel",
  ...
  "attachments": [
    {
      ...
      "pretext": "Issue *#3* from [redacted] / [redacted]",
      "author_name": "Jeff Mixon",
      "author_link": "",
      "author_icon": "/uploads/-/system/user/avatar/19/avatar.png",
      "title": "title · #3",
      "title_link": "https://git.[redacted].com/[redacted]/[redacted]/-/issues/3",
      "text": "**Open**",
      ...
    }
  ],
  "extra_responses": null
}

Output of checks

(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)

Results of GitLab environment info

Expand for output related to GitLab environment info

System information
System:		Debian 8.11
Proxy:		[redacted]
Current User:	git
Using RVM:	no
Ruby Version:	2.6.5p114
Gem Version:	2.7.10
Bundler Version:1.17.3
Rake Version:	12.3.3
Redis Version:	5.0.7
Git Version:	2.24.1
Sidekiq Version:5.2.7
Go Version:	unknown

GitLab information
Version:	12.9.0-ee
Revision:	073a4ba8016
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	PostgreSQL
DB Version:	10.12
URL:		https://git.[redacted].com
HTTP Clone URL:	https://git.[redacted].com/some-group/some-project.git
SSH Clone URL:	git@git.[redacted].com:some-group/some-project.git
Elasticsearch:	yes
Geo:		no
Using LDAP:	yes
Using Omniauth:	yes
Omniauth Providers: 

GitLab Shell
Version:	12.0.0
Repository storage paths:
- default: 	/var/opt/gitlab/git-data/repositories
GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell
Git:		/opt/gitlab/embedded/bin/git

Results of GitLab application Check

Expand for output related to the GitLab application check

Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 12.0.0 ? ... OK (12.0.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) User output sanitized. Found 17 users of 100 limit.

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 3/3 ... yes 8/5 ... yes 3/6 ... yes 7/7 ... yes 3/8 ... yes 3/13 ... yes 15/14 ... yes 15/15 ... yes 15/16 ... yes 3/20 ... yes 24/21 ... yes 3/22 ... yes 3/23 ... yes 3/25 ... yes 8/31 ... yes 8/33 ... yes 8/34 ... yes 8/35 ... yes 8/36 ... yes 8/38 ... yes 21/39 ... yes 21/40 ... yes 21/41 ... yes 21/42 ... yes 8/43 ... yes 3/50 ... yes 3/51 ... yes 15/52 ... yes 3/53 ... yes 21/54 ... yes 3/56 ... yes 48/57 ... yes 3/58 ... yes 36/59 ... yes 23/60 ... yes 5/61 ... yes 48/62 ... yes 3/63 ... yes 15/64 ... yes 3/65 ... yes 23/66 ... yes 48/68 ... yes 3/69 ... yes 36/71 ... yes 48/73 ... yes 38/74 ... yes 48/75 ... yes 3/76 ... yes 3/77 ... yes 36/79 ... yes 36/80 ... yes 36/81 ... yes 36/82 ... yes 38/83 ... yes 34/84 ... yes 36/85 ... yes 7/86 ... yes 36/87 ... yes 38/88 ... yes 36/92 ... yes 23/93 ... yes 41/94 ... yes 36/95 ... yes 38/96 ... yes 36/99 ... yes 36/100 ... yes 36/101 ... yes 43/102 ... yes 7/103 ... yes 36/105 ... yes 41/107 ... yes 23/108 ... yes 38/109 ... yes 36/110 ... yes 36/111 ... yes 3/112 ... yes 3/113 ... yes 60/114 ... yes 36/115 ... yes 3/116 ... yes 38/117 ... yes 3/118 ... yes 36/119 ... yes 3/120 ... yes 38/121 ... yes 36/122 ... yes 23/123 ... yes 23/124 ... yes 38/125 ... yes 38/126 ... yes 38/127 ... yes 38/128 ... yes 7/129 ... yes 48/130 ... yes 36/131 ... yes 3/132 ... yes 23/133 ... yes 3/134 ... yes 3/135 ... yes 47/137 ... yes 38/138 ... yes 3/139 ... yes 23/140 ... yes 7/141 ... yes 7/142 ... yes 36/143 ... yes 38/144 ... yes 38/145 ... yes 3/148 ... yes 41/150 ... yes 48/151 ... yes 43/152 ... yes 41/153 ... yes 36/154 ... yes 3/155 ... yes 3/156 ... yes 3/157 ... yes 41/158 ... yes 52/159 ... yes 52/160 ... yes 52/161 ... yes 48/162 ... yes 41/163 ... yes 2/164 ... yes 36/165 ... yes 23/166 ... yes 48/167 ... yes 48/168 ... yes 36/170 ... yes 48/171 ... yes 48/172 ... yes 48/173 ... yes 7/174 ... yes 23/176 ... yes 36/177 ... yes 23/178 ... yes 36/179 ... yes 38/180 ... yes 49/181 ... yes 48/183 ... yes 23/185 ... yes 36/186 ... yes 48/187 ... yes 36/188 ... yes 48/189 ... yes 48/190 ... yes 48/191 ... yes 36/192 ... yes 48/193 ... yes 60/195 ... yes 48/196 ... yes 38/197 ... yes 36/198 ... yes 38/199 ... yes 60/200 ... yes 23/201 ... yes 48/202 ... yes 48/203 ... yes 36/204 ... yes 49/205 ... yes 48/206 ... yes 38/207 ... yes 23/208 ... yes 36/209 ... yes 7/210 ... yes 7/211 ... yes 7/212 ... yes 48/213 ... yes 36/214 ... yes 7/215 ... yes 38/218 ... yes 7/219 ... yes 38/220 ... yes 7/221 ... yes 67/222 ... yes 67/223 ... yes 67/224 ... yes 38/225 ... yes 38/226 ... yes 68/227 ... yes 69/228 ... yes 3/229 ... yes 48/230 ... yes 48/231 ... yes 48/232 ... yes 69/233 ... yes 23/234 ... yes 38/235 ... yes 67/236 ... yes 67/237 ... yes 67/238 ... yes 69/239 ... yes 69/240 ... yes 7/241 ... yes 67/242 ... yes 67/243 ... yes 67/244 ... yes 67/245 ... yes 67/246 ... yes 67/247 ... yes 23/249 ... yes 69/250 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.5.3 ? ... yes (2.6.5) Git version >= 2.22.0 ? ... yes (2.24.1) Git user has default SSH configuration? ... no Try fixing it: mkdir ~/gitlab-check-backup-1585084446 sudo mv /var/opt/gitlab/.ssh/id_rsa.pub ~/gitlab-check-backup-1585084446 sudo mv /var/opt/gitlab/.ssh/id_rsa ~/gitlab-check-backup-1585084446 For more information see: doc/ssh/README.md in section "SSH on the GitLab server" Please fix the error above and rerun the checks. Active users: ... 10 Is authorized keys file accessible? ... yes Elasticsearch version 5.6 - 6.x? ... yes (6.7.0)

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Possible fixes

Adding only_path: false fixes the issue:

https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/slash_commands/presenters/base.rb#L94

root@git:/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/slash_commands/presenters# diff base.rb.orig base.rb 
94c94
<                 author_icon:  author.avatar_url,
---
>                 author_icon:  author.avatar_url(only_path: false),

After patch applied:

{
  "response_type": "in_channel",
  ...
  "attachments": [
    {
      ...
      "pretext": "Issue *#3* from [redacted] / [redacted]",
      "author_name": "Jeff Mixon",
      "author_link": "",
      "author_icon": "https://git.[redacted].com/uploads/-/system/user/avatar/19/avatar.png",
      "title": "title · #3",
      "title_link": "https://git.[redacted].com/[redacted]/[redacted]/-/issues/3",
      "text": "**Open**",
      ...
    }
  ],
  "extra_responses": null
}