Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fetching variable with environment scope raises 409 complaining about multiple variables with same key #3202

Open
@elucify

Description

@elucify

Description of the problem, including code/CLI snippet

When attempting to fetch a project variable with a specificenvironment_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 passingenvironment_scope norfilter_environment_scope as arguments toProjectVariableManager.get() resolves the error409: There are multiple variables with provided parameters. Please use 'filter[environment_scope]' even when only two variables exist with unique environment scopes.

Example (all fail with 409 error):

src.variables.get("PUBLISH_TIMEOUT", "*")src.variables.get("PUBLISH_TIMEOUT", environment_scope="*")src.variables.get("PUBLISH_TIMEOUT", filter_environment_scope="*")

The only way to successfully fetch the correct variable is by using the undocumentedquery_parameters argument, as discovered by reading the source code:

src.variables.get(p.key,query_parameters={"filter[environment_scope]": p.environment_scope})

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

Expected Behavior

Passing eitherenvironment_scope orfilter_environment_scope as an argument toProjectVariableManager.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.

Actual Behavior

Passingenvironment_scope orfilter_environment_scope as arguments toget() results in a 409 error from the API:

gitlab.exceptions.GitlabGetError: 409: There are multiple variables with provided parameters. Please use 'filter[environment_scope]'

The only way to successfully retrieve the variable is by passing the filter as aquery_parameters dictionary, which is not documented (at least, not in the places where the documentation would be of use):

src.variables.get(p.key,query_parameters={"filter[environment_scope]": p.environment_scope})

Specifications

  • python-gitlab version: 5.6.0
  • Gitlab server version (or gitlab.com): v17.6.5-ee

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp