Title: Fetching variable with environment scope raises 409 complaining about multiple variables with same key · Issue #3202 · python-gitlab/python-gitlab · GitHub
Open Graph Title: Fetching variable with environment scope raises 409 complaining about multiple variables with same key · Issue #3202 · python-gitlab/python-gitlab
X Title: Fetching variable with environment scope raises 409 complaining about multiple variables with same key · Issue #3202 · python-gitlab/python-gitlab
Description: Description of the problem, including code/CLI snippet When attempting to fetch a project variable with a specific environment_scope using the python-gitlab API (v5.6.0) against GitLab server (17.6.5-ee), the documented and intuitive app...
Open Graph Description: Description of the problem, including code/CLI snippet When attempting to fetch a project variable with a specific environment_scope using the python-gitlab API (v5.6.0) against GitLab server (17.6...
X Description: Description of the problem, including code/CLI snippet When attempting to fetch a project variable with a specific environment_scope using the python-gitlab API (v5.6.0) against GitLab server (17.6...
Opengraph URL: https://github.com/python-gitlab/python-gitlab/issues/3202
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fetching variable with environment scope raises 409 complaining about multiple variables with same key","articleBody":"\n\n## Description of the problem, including code/CLI snippet\n\nWhen attempting to fetch a project variable with a specific `environment_scope` using the python-gitlab API (v5.6.0) against GitLab server (17.6.5-ee), the documented and intuitive approaches do not work. Specifically, neither passing `environment_scope` nor `filter_environment_scope` as arguments to `ProjectVariableManager.get()` resolves the error `409: There are multiple variables with provided parameters. Please use 'filter[environment_scope]'` even when only two variables exist with unique environment scopes.\n\nExample (all fail with 409 error):\n\n```\nsrc.variables.get(\"PUBLISH_TIMEOUT\", \"*\")\nsrc.variables.get(\"PUBLISH_TIMEOUT\", environment_scope=\"*\")\nsrc.variables.get(\"PUBLISH_TIMEOUT\", filter_environment_scope=\"*\")\n```\n\nThe only way to successfully fetch the correct variable is by using the undocumented `query_parameters` argument, as discovered by reading the source code:\n\n```\nsrc.variables.get(\np.key,\nquery_parameters={\"filter[environment_scope]\": p.environment_scope}\n)\n```\n\nThis workaround is not documented and the error message does not guide the user to this solution. The documentation and exception message should be updated to clarify the correct usage.\n\n## Expected Behavior\n\nPassing either `environment_scope` or `filter_environment_scope` as an argument to `ProjectVariableManager.get()` should allow selection of the correct variable when multiple variables share the same key but have different environment scopes, as described in the GitLab API documentation. The library should transparently handle the filter parameter, or at least document the correct usage.\n\n## Actual Behavior\n\nPassing `environment_scope` or `filter_environment_scope` as arguments to `get()` results in a 409 error from the API:\n\n```\ngitlab.exceptions.GitlabGetError: 409: There are multiple variables with provided parameters. Please use 'filter[environment_scope]'\n```\n\nThe only way to successfully retrieve the variable is by passing the filter as a `query_parameters` dictionary, which is not documented (at least, not in the places where the documentation would be of use):\n\n```\nsrc.variables.get(\np.key,\nquery_parameters={\"filter[environment_scope]\": p.environment_scope}\n)\n```\n\n## Specifications\n\n- python-gitlab version: 5.6.0\n- Gitlab server version (or gitlab.com): v17.6.5-ee\n","author":{"url":"https://github.com/elucify","@type":"Person","name":"elucify"},"datePublished":"2025-05-21T18:47:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/3202/python-gitlab/issues/3202"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bbc338a5-550c-dd4f-dc30-2bf933bdbd05 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D3EC:684B7:1CBCBD6:24C5E38:6975D495 |
| html-safe-nonce | 47e6efd76c68ad7125f5c3ae58694bf11f6ddc50ea6abf7dc63f542fd27c305b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0VDOjY4NEI3OjFDQkNCRDY6MjRDNUUzODo2OTc1RDQ5NSIsInZpc2l0b3JfaWQiOiIyNDQ0MTg5NzEzMTI3MDY3MDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bab98e974d66208ea1c9d77bf821b24bbf24ac1ebdfca810eb35d50bde5814e2 |
| hovercard-subject-tag | issue:3081128439 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-gitlab/python-gitlab/3202/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2afaace2677c11aa51838ab18cbffc67c0f44f7834608d8024a3ad7fd69beae2/python-gitlab/python-gitlab/issues/3202 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2afaace2677c11aa51838ab18cbffc67c0f44f7834608d8024a3ad7fd69beae2/python-gitlab/python-gitlab/issues/3202 |
| og:image:alt | Description of the problem, including code/CLI snippet When attempting to fetch a project variable with a specific environment_scope using the python-gitlab API (v5.6.0) against GitLab server (17.6... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | elucify |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2bce766e7450b03e00b2fc5badd417927ce33a860e78cda3e4ecb9bbd1374cc6 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-gitlab/python-gitlab git https://github.com/python-gitlab/python-gitlab.git |
| octolytics-dimension-user_id | 28886265 |
| octolytics-dimension-user_login | python-gitlab |
| octolytics-dimension-repository_id | 8077625 |
| octolytics-dimension-repository_nwo | python-gitlab/python-gitlab |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 8077625 |
| octolytics-dimension-repository_network_root_nwo | python-gitlab/python-gitlab |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | fcca2b8ef702b5f7f91427a6e920fa44446fe312 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width