Gitlab API for environments name/search filtering not working

Hey all, I am a bit boggled on this one.

If anyone has deep familiarity with the API and/or gitlab environments, would appreciate some eyeballs.

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!!
...

:x:

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'
...

:x:

curl --header "PRIVATE-TOKEN: ${PRIVATE_TOKEN}" ${PROJECT_URI}/api/v4/projects/${PROJECT_ID}/environments?search=master | jq '.[] | .name'
...

:x:

I wondered if it was because the environment has numerics in there … created a dev environment that doesn’t have that, still doesn’t work!

curl --header "PRIVATE-TOKEN: ${PRIVATE_TOKEN}" ${PROJECT_URI}/api/v4/projects/${PROJECT_ID}/environments?name=dev%2Ffuntime
...

:x:

kind of boggled …

getting the SPECIFIC environment does work as expected (but I need the above to work in order to get the internal gitlab environment ID)

$ curl --header "PRIVATE-TOKEN: ${PRIVATE_TOKEN}" ${PROJECT_URI}/api/v4/projects/${PROJECT_ID}/environments/904 | jq '.name' 
(snip)
"master/3526"

:heavy_check_mark:

WORKAROUND:

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

This is a bit dangerous due to pagination … (or at least adds complexity having to traverse pages if there are >100 environments at any given time).

As best I can tell, this is a legitimate issue/bug, submitted in: https://gitlab.com/gitlab-org/gitlab-foss/issues/67541