GitLab merge request payloads show nil for `.changes.labels.previous`
### Summary
Certain payloads for merge request events (i.e. "rebase" on MR) will give an empty array for `.changes.labels.previous` regardless of what the previous labels were. We have a bot that does things (not idempotent) when a certain label is added. We'd like not to keep state so we check if the label was already present in `.changes.labels.previous` before performing this action. Problem is that this field is not alway correct and often shows empty.
### Steps to reproduce
* Create a merge request
* add a label -> payload is correct
* rebase merge request -> payload is not correct, `.changes.labels.previous` is `[]`
### What is the current *bug* behavior?
Certain payloads for merge request events will always give an empty array for `.changes.labels.previous`.
### What is the expected *correct* behavior?
Show whatever were the previous labels in `.changes.labels.previous`.
#### Results of GitLab environment info
<details>
<summary>Expand for output related to GitLab environment info</summary>
<pre>
steven@gitlab:~$ sudo gitlab-rake gitlab:env:info
System information
System: Ubuntu 16.04
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 2.3.6p384
Gem Version: 2.6.13
Bundler Version:1.13.7
Rake Version: 12.3.0
Redis Version: 3.2.11
Git Version: 2.14.3
Sidekiq Version:5.0.5
Go Version: unknown
GitLab information
Version: 10.7.0-ee
Revision: 53adfd5
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: postgresql
DB Version: 9.6.8
URL: https://gitlab.silverfin.com
HTTP Clone URL: https://gitlab.silverfin.com/some-group/some-project.git
SSH Clone URL: git@gitlab.silverfin.com:some-group/some-project.git
Elasticsearch: yes
Geo: no
Using LDAP: no
Using Omniauth: yes
Omniauth Providers: google_oauth2, github
GitLab Shell
Version: 7.1.2
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks
Git: /opt/gitlab/embedded/bin/git
</pre>
</details>
#### Results of GitLab application Check
<details>
<summary>Expand for output related to the GitLab application check</summary>
<pre>
steven@gitlab:~$ sudo gitlab-rake gitlab:check SANITIZE=true
Checking GitLab Shell ...
GitLab Shell version >= 7.1.2 ? ... OK (7.1.2)
Repo base directory exists?
default... yes
Repo storage directories are symlinks?
default... no
Repo paths owned by git:root, or git:git?
default... yes
Repo paths access is drwxrws---?
default... yes
hooks directories in repos are links: ...
10/10 ... ok
10/11 ... ok
10/12 ... ok
10/13 ... ok
9/20 ... ok
11/24 ... ok
9/28 ... ok
10/30 ... ok
10/37 ... ok
9/42 ... ok
10/43 ... ok
11/44 ... ok
11/52 ... ok
9/55 ... ok
9/57 ... ok
30/58 ... ok
3/59 ... ok
3/60 ... ok
3/61 ... ok
3/62 ... ok
3/63 ... ok
3/65 ... ok
3/66 ... ok
3/67 ... ok
3/68 ... ok
3/69 ... ok
3/70 ... ok
3/71 ... ok
3/72 ... ok
3/73 ... ok
3/74 ... ok
3/75 ... ok
3/76 ... ok
3/77 ... ok
3/78 ... ok
3/80 ... ok
3/81 ... ok
3/82 ... ok
3/83 ... ok
3/84 ... ok
3/85 ... ok
3/86 ... ok
3/87 ... ok
3/88 ... ok
3/89 ... ok
3/90 ... ok
3/91 ... ok
3/93 ... ok
3/94 ... repository is empty
3/95 ... ok
3/96 ... ok
3/98 ... ok
3/103 ... ok
3/104 ... ok
3/105 ... ok
3/107 ... ok
3/108 ... ok
3/113 ... ok
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Check GitLab API access: OK
Redis available via internal API: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK
gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes
Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Reply by email is disabled in config/gitlab.yml
Checking LDAP ...
LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab ...
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: ...
10/10 ... yes
10/11 ... yes
10/12 ... yes
10/13 ... yes
9/20 ... yes
11/24 ... yes
9/28 ... yes
10/30 ... yes
10/37 ... yes
9/42 ... yes
10/43 ... yes
11/44 ... yes
11/52 ... yes
9/55 ... yes
9/57 ... yes
30/58 ... yes
3/59 ... yes
3/60 ... yes
3/61 ... yes
3/62 ... yes
3/63 ... yes
3/65 ... yes
3/66 ... yes
3/67 ... yes
3/68 ... yes
3/69 ... yes
3/70 ... yes
3/71 ... yes
3/72 ... yes
3/73 ... yes
3/74 ... yes
3/75 ... yes
3/76 ... yes
3/77 ... yes
3/78 ... yes
3/80 ... yes
3/81 ... yes
3/82 ... yes
3/83 ... yes
3/84 ... yes
3/85 ... yes
3/86 ... yes
3/87 ... yes
3/88 ... yes
3/89 ... yes
3/90 ... yes
3/91 ... yes
3/93 ... yes
3/94 ... yes
3/95 ... yes
3/96 ... yes
3/98 ... yes
3/103 ... yes
3/104 ... yes
3/105 ... yes
3/107 ... yes
3/108 ... yes
3/113 ... yes
Redis version >= 2.8.0? ... yes
Ruby version >= 2.3.5 ? ... yes (2.3.6)
Git version >= 2.9.5 ? ... yes (2.14.3)
Git user has default SSH configuration? ... yes
Active users: ... 31
Elasticsearch version 5.1 - 5.5? ... no (5.6.9)
For more information see:
doc/integration/elastcsearch.md
Checking GitLab ... Finished
</pre>
</details>
### Possible fixes
(If you can, link to the line of code that might be responsible for the problem)
issue