Basic Search by filename does not support wildcard match
Summary
I have a repository with some files including
- composer.json
- composer.lock
When I use the search api:
GET host/api/v4/projects/:id/search?scope=blobs&ref=master&search=* filename:composer.json
It does'nt returns anything
But when I do GET host/api/v4/projects/:id/search?scope=blobs&ref=master&search=* filename:composer.lock
It find (several times) the composer.lock file
It behaves exactly the same on some other repositories with package.json
(no result) and package-lock.json
(several matches)
Is it normal?
Why does it match several times the same file ?
Why can't it find composer.json
or package.json
Steps to reproduce
GET https://gitlab.com/api/v4/projects/18890336/search?scope=blobs&ref=master&search=*%20filename:composer.json
[]
GET https://gitlab.com/api/v4/projects/18890336/search?scope=blobs&ref=master&search=*%20filename:composer.lock
[
{
"basename":"composer",
"data":" },\n \"require-dev\": {\n \"phpunit/phpunit\": \"4.*|5.*\",\n \"vimeo/psalm\": \"^1\"\n },\n",
"path":"composer.lock",
"filename":"composer.lock",
"id":null,
"ref":"master",
"startline":25,
"project_id":18890336
},
{
"basename":"composer",
"data":" },\n \"require\": {\n \"ext-ctype\": \"*\",\n \"ext-filter\": \"*\",\n \"php\": \"\u003e=5.5.0\"\n },\n",
"path":"composer.lock",
"filename":"composer.lock",
"id":null,
"ref":"master",
"startline":67,
"project_id":18890336
},
{
"basename":"composer",
"data":" },\n \"require\": {\n \"ext-openssl\": \"*\",\n \"ext-pcre\": \"*\",\n \"php\": \"^5.3.2 || ^7.0 || ^8.0\"\n },\n",
"path":"composer.lock",
"filename":"composer.lock",
"id":null,
"ref":"master",
"startline":1055,
"project_id":18890336
}
]
Example Project
https://gitlab.com/jeremy.cohen-solal.fintech/api-search-by-filename-issue
What is the current bug behavior?
When I search for a composer.json
file (* filename:composer.json) it doesnt find any file.
Same with package.json
and package-lock.json
What is the expected correct behavior?
I think
- when I use search=* filename:composer.lock I should see 1 result composer.lock
- when I use search=* filename:composer.json I should see 1 result composer.json
- when I use search=* filename:package-lock.json I should see 1 result package-lock.json
- when I use search=* filename:package.json I should see 1 result package.json
Output of checks
This bug happens on GitLab.com AND on the OnPremise edition!