Label doesn't exist bug
I currently use version 1.8.0
of gitlab-triage
with Ruby 2.7.0 on Ubuntu 20.04.
If I update to version 1.11.0
I find a number of my policies give LabelDoesntExistError
s.
Example policy and traceback
For example, this policy:
resource_rules:
merge_requests:
rules:
- name: MR without WIP marker must be labelled under review
conditions:
state: opened
forbidden_labels:
- Under Review
ruby: |
!resource[:work_in_progress]
actions:
labels:
- Under Review
now gives errors like this:
Performing a dry run.
===================================
Triaging the `GROUP` group
===================================
...
----------------------------------------------------------------------------
Gathering resources for rule: **MR without WIP marker must be under review**
----------------------------------------------------------------------------
.[DEBUG] query_api: https://gitlab.com/api/v4/groups/GROUP/merge_requests?per_page=100¬[labels]=Under Review&state=opened
[DEBUG] rate_limit_infos: Rate limit remaining: 594 (reset at 2020-08-18 18:58:00 +0100)
* Found 17 resources...
* Filtering resources...
* Total after filtering: 2 resources
* Limiting resources...
* Total after limiting: 2 resources
The following comments would be posted for the rule **MR without WIP marker must be under review**:
.[DEBUG] query_api: https://gitlab.com/api/v4/projects/PROJECTID/labels/Under+Review?per_page=100
[DEBUG] rate_limit_infos: Rate limit remaining: 593 (reset at 2020-08-18 18:58:01 +0100)
Traceback (most recent call last):
31: from .../vendor/bundle/ruby/2.7.0/bin/gitlab-triage:23:in `<main>'
30: from .../vendor/bundle/ruby/2.7.0/bin/gitlab-triage:23:in `load'
29: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/bin/gitlab-triage:10:in `<top (required)>'
28: from /usr/lib/ruby/2.7.0/set.rb:328:in `each'
27: from /usr/lib/ruby/2.7.0/set.rb:328:in `each_key'
26: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/bin/gitlab-triage:15:in `block in <top (required)>'
25: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/engine.rb:52:in `perform'
24: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/engine.rb:52:in `each'
23: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/engine.rb:57:in `block in perform'
22: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/engine.rb:116:in `process_rules'
21: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/engine.rb:116:in `each'
20: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/engine.rb:117:in `block in process_rules'
19: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/engine.rb:157:in `resources_for_rule'
18: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/expand_condition.rb:13:in `perform'
17: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/expand_condition.rb:13:in `each'
16: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/engine.rb:173:in `block in resources_for_rule'
15: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/engine.rb:121:in `block (2 levels) in process_rules'
14: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/engine.rb:184:in `process_action'
13: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/action.rb:11:in `process'
12: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/action.rb:11:in `each'
11: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/action.rb:12:in `block in process'
10: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/action.rb:24:in `act'
9: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/action/comment.rb:20:in `act'
8: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/action/comment.rb:31:in `act'
7: from /usr/lib/ruby/2.7.0/forwardable.rb:235:in `each'
6: from /usr/lib/ruby/2.7.0/forwardable.rb:235:in `each'
5: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/action/comment.rb:32:in `block in act'
4: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/action/comment.rb:44:in `build_comment'
3: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/command_builders/label_command_builder.rb:8:in `build_command'
2: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/command_builders/label_command_builder.rb:16:in `ensure_labels_exist!'
1: from .../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/command_builders/label_command_builder.rb:16:in `each'
.../vendor/bundle/ruby/2.7.0/gems/gitlab-triage-1.11.0/lib/gitlab/triage/command_builders/label_command_builder.rb:20:in `block in ensure_labels_exist!': Label `Under Review` doesn't exist! (Gitlab::Triage::Resource::Label::LabelDoesntExistError)
In the example above PROJECTID
refers to a project which is a subgroup of GROUP
and the label Under Review
is defined in GROUP
. All the failing policies relate to projects and labels that have this structure.
In the browser, the API call https://gitlab.com/api/v4/projects/PROJECTID/labels/Under+Review?per_page=100
does give the response {"message":"404 Label Not Found"}
.
Dependencies
$ cat Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
activesupport (5.2.4.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
concurrent-ruby (1.1.7)
diff-lcs (1.4.4)
docopt (0.6.1)
gitlab-triage (1.11.0)
activesupport (~> 5.1)
httparty (~> 0.17)
httparty (0.18.1)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.0512)
minitest (5.14.1)
multi_xml (0.6.0)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
thread_safe (0.3.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
PLATFORMS
ruby
DEPENDENCIES
docopt
gitlab-triage
httparty
rspec
BUNDLED WITH
2.1.4