Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e9dcf27c
Commit
e9dcf27c
authored
Dec 10, 2020
by
Changzheng Liu
Committed by
Kerri Miller
Dec 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore Issue and MR IID search out of range error
parent
43667b2f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
15 deletions
+30
-15
ee/changelogs/unreleased/287661_lenient_iid_outofrange.yml
ee/changelogs/unreleased/287661_lenient_iid_outofrange.yml
+5
-0
ee/lib/elastic/latest/application_class_proxy.rb
ee/lib/elastic/latest/application_class_proxy.rb
+1
-0
ee/lib/elastic/latest/issue_class_proxy.rb
ee/lib/elastic/latest/issue_class_proxy.rb
+3
-7
ee/lib/elastic/latest/merge_request_class_proxy.rb
ee/lib/elastic/latest/merge_request_class_proxy.rb
+3
-7
ee/spec/lib/gitlab/elastic/search_results_spec.rb
ee/spec/lib/gitlab/elastic/search_results_spec.rb
+18
-1
No files found.
ee/changelogs/unreleased/287661_lenient_iid_outofrange.yml
0 → 100644
View file @
e9dcf27c
---
title
:
Ignore Issue and MR IID search out of range error
merge_request
:
49284
author
:
type
:
fixed
ee/lib/elastic/latest/application_class_proxy.rb
View file @
e9dcf27c
...
...
@@ -67,6 +67,7 @@ module Elastic
_name:
context
.
name
(
self
.
es_type
,
:match
,
:search_terms
),
fields:
fields
,
query:
query
,
lenient:
true
,
default_operator:
default_operator
}
}],
...
...
ee/lib/elastic/latest/issue_class_proxy.rb
View file @
e9dcf27c
...
...
@@ -10,13 +10,9 @@ module Elastic
if
query
=~
/#(\d+)\z/
iid_query_hash
(
Regexp
.
last_match
(
1
))
else
fields
=
%w(title^2 description)
# We can only allow searching the iid field if the query is
# just a number, otherwise Elasticsearch will error since this
# field is type integer.
fields
<<
"iid^3"
if
query
=~
/\A\d+\z/
# iid field can be added here as lenient option will
# pardon format errors, like integer out of range.
fields
=
%w(iid^3 title^2 description)
basic_query_hash
(
fields
,
query
)
end
...
...
ee/lib/elastic/latest/merge_request_class_proxy.rb
View file @
e9dcf27c
...
...
@@ -10,13 +10,9 @@ module Elastic
if
query
=~
/\!(\d+)\z/
iid_query_hash
(
Regexp
.
last_match
(
1
))
else
fields
=
%w(title^2 description)
# We can only allow searching the iid field if the query is
# just a number, otherwise Elasticsearch will error since this
# field is type integer.
fields
<<
"iid^3"
if
query
=~
/\A\d+\z/
# iid field can be added here as lenient option will
# pardon format errors, like integer out of range.
fields
=
%w(iid^3 title^2 description)
basic_query_hash
(
fields
,
query
)
end
...
...
ee/spec/lib/gitlab/elastic/search_results_spec.rb
View file @
e9dcf27c
...
...
@@ -204,7 +204,7 @@ RSpec.describe Gitlab::Elastic::SearchResults, :elastic, :sidekiq_might_not_need
describe
'issues'
do
let
(
:scope
)
{
'issues'
}
let!
(
:issue_1
)
{
create
(
:issue
,
project:
project_1
,
title:
'Hello world, here I am!'
,
iid:
1
)
}
let!
(
:issue_1
)
{
create
(
:issue
,
project:
project_1
,
title:
'Hello world, here I am!'
,
description:
'20200623170000, see details in issue 287661'
,
iid:
1
)
}
let!
(
:issue_2
)
{
create
(
:issue
,
project:
project_1
,
title:
'Issue Two'
,
description:
'Hello world, here I am!'
,
iid:
2
)
}
let!
(
:issue_3
)
{
create
(
:issue
,
project:
project_2
,
title:
'Issue Three'
,
iid:
2
)
}
...
...
@@ -245,6 +245,14 @@ RSpec.describe Gitlab::Elastic::SearchResults, :elastic, :sidekiq_might_not_need
expect
(
results
.
issues_count
).
to
eq
1
end
it
'finds the issue with an out of integer range number in its description without exception'
do
results
=
described_class
.
new
(
user
,
'20200623170000'
,
limit_project_ids
,
public_and_internal_projects:
false
)
issues
=
results
.
objects
(
'issues'
)
expect
(
issues
).
to
contain_exactly
(
issue_1
)
expect
(
results
.
issues_count
).
to
eq
1
end
it
'returns empty list when search by invalid iid'
do
results
=
described_class
.
new
(
user
,
'#222'
,
limit_project_ids
)
...
...
@@ -546,6 +554,7 @@ RSpec.describe Gitlab::Elastic::SearchResults, :elastic, :sidekiq_might_not_need
source_project:
project_1
,
target_project:
project_1
,
title:
'Hello world, here I am!'
,
description:
'20200623170000, see details in issue 287661'
,
iid:
1
)
@merge_request_2
=
create
(
...
...
@@ -601,6 +610,14 @@ RSpec.describe Gitlab::Elastic::SearchResults, :elastic, :sidekiq_might_not_need
expect
(
results
.
merge_requests_count
).
to
eq
1
end
it
'finds the MR with an out of integer range number in its description without exception'
do
results
=
described_class
.
new
(
user
,
'20200623170000'
,
limit_project_ids
,
public_and_internal_projects:
false
)
merge_requests
=
results
.
objects
(
'merge_requests'
)
expect
(
merge_requests
).
to
contain_exactly
(
@merge_request_1
)
expect
(
results
.
merge_requests_count
).
to
eq
1
end
it
'returns empty list when search by invalid iid'
do
results
=
described_class
.
new
(
user
,
'#222'
,
limit_project_ids
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment