Gitlab API for environments name/search filtering not working
### Summary The gitlab REST API for querying environments by name or search does not work. ### Steps to reproduce See https://forum.gitlab.com/t/gitlab-api-for-environments-name-search-filtering-not-working/31983 consider a desire to find an environment ID by name ``` PRIVATE_TOKEN="..." PROJECT_URI="https://..." PROJECT_ID="XX" ``` As per this the documentation describes precisely what I want. https://docs.gitlab.com/ee/api/environments.html#list-environments `?name=` & `?search=` experimenting with the basic query, I can see my environments in the BULK get ``` curl --header "PRIVATE-TOKEN: ${PRIVATE_TOKEN}" ${PROJECT_URI}/api/v4/projects/${PROJECT_ID}/environments?per_page=100 | jq '.[] | .name' | grep master/ (snip) "master/3524" "master/3525" "master/3526" ``` :heavy_check_mark: but my goal is to get the ID of a specific environment, by a specific name, so lets say I want “master/3524” ``` $ curl --header "PRIVATE-TOKEN: ${PRIVATE_TOKEN}" ${PROJECT_URI}/api/v4/projects/${PROJECT_ID}/environments?name=master%2F3524 | jq '.[] | .name' (SNIP) ... lists ALL environments!! ... ``` :exclamation: it doesn’t match, in the documentation example, it is quite clear that / needs to be %2F (verified https://en.wikipedia.org/wiki/Percent-encoding) , i tried / directly, … but of course this doesn’t work because / is a reserved character, it needs to be % encoded tried the search filter as well, same problem ``` curl --header "PRIVATE-TOKEN: ${PRIVATE_TOKEN}" ${PROJECT_URI}/api/v4/projects/${PROJECT_ID}/environments?search=3524 | jq '.[] | .name' ... lists ALL environments!! ... ``` :exclamation: (tried various other attempts/combinations, see the forum post) ### Example Project (did not do) ### What is the current *bug* behavior? The API query to "List environments" works without any parameters (lists all environments). However the query to specify an environment by `name` or by `search` does not work. ### What is the expected *correct* behavior? ``` curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/1/environments?name=review%2Ffix-foo ``` , per the documentation: https://docs.gitlab.com/ee/api/environments.html#list-environments Should work. ### Relevant logs and/or screenshots N/A ### Output of checks see above #### Results of GitLab environment info gitlab instance version `11.11.2` #### Results of GitLab application Check (skipped) ### Possible fixes WORKAROUND I found was to list ALL environments, and filter using `jq`. https://forum.gitlab.com/t/gitlab-api-for-environments-name-search-filtering-not-working/31983/2 ``` curl --silent --header "PRIVATE-TOKEN: ${PRIVATE_TOKEN}" ${PROJECT_URI}/api/v4/projects/${PROJECT_ID}/environments?per_page=100 | jq '.[] | select(.name == "master/3526")' | jq '.id' 904 ```
issue