-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
community.general.gitlab_group module fails without optional arguments #4577
Comments
Files identified in the description: If these files are incorrect, please update the |
The GitLab instance probably does not like getting sent null parameters as payload, so these'll need to be added only when defined - like some of the other options just below: community.general/plugins/modules/source_control/gitlab/gitlab_group.py Lines 204 to 217 in 7ee38ea
|
@nejch i saw this in the gitlab server logs. I think your assumption is correct. Gitlab does not like to see null on some of these options.
|
Before someone starts a PR with a hardcoded fix, I'll just point out - it's hard to keep up with all the parameters that can be sent to GitLab and many are added (potentially every month) or deprecated and removed (once a year) with new GitLab versions. Take a look at the create group API: Or worse the create project API: That's over 60 parameters of which the I'd almost prefer a looser schema where the user defines any extra - name: "Create GitLab Group"
community.general.gitlab_group:
api_url: https://git.example.com/
validate_certs: False
api_username: "test"
api_password: "test"
state: present
attributes:
name: my_first_group
path: my_first_group
description: "test"
parent: "parent"
subgroup_creation_level: maintainer
project_creation_level: maintainer The downside is there's less validation, though I think the module could provide some helpful feedback based on the server's response as well. The 500 is unfortunate in the logs above, I think usually it would be a 405 with a more descriptive error. You can also see this dilemma in https://github.com/ansible-collections/community.general/pull/2129/files#diff-9718af78820fd1f29c9b83d5d861a1271a46c4266d49dc6267466e0a5d0ea68cR240 where there's a snapshot of many options that will only really be true for a certain version of GitLab. I think instead it's possibly easier to point to the upstream API docs instead so that multiple versions can be supported in a kind of agnostic way (at least where possible). Not sure if any other modules already use this approach, and obviously this would be a breaking change at some point. Any thoughts on this @felixfontein? (Edit: this might deserve its own issue, just wanted to start a discussion) |
@nejch that's a really good question, and I don't have a good answer to it. It's probably best to start a new discussion in a new issue :) (Sorry for taking so long to answer, I've looked at it repeatedly and never had a really great idea...) I think there are two perspectives:
Combining both perspectives in the same module can be hard. Also handling perspective 2 if there are options that take more complex values (say a list of dictionaries), handling these generically is hard and probably next to impossible for all cases these values can be used for. So maybe there should be two modules? On the other hand, having two modules for the same thing potentially causes even more confusion and unnecessary complexity... |
Files identified in the description: If these files are incorrect, please update the |
Summary
When i try to run community.general.gitlab_group module without specifying "subgroup_creation_level" or "project_creation_level", the task fails with gitlab error 500. Both arguments are not specified as "required" in the module documentation. I ran this task against Gitlab EE 14.7.6.
Example without specifying "subgroup_creation_level":
Issue Type
Bug Report
Component Name
community.general.gitlab_group
Ansible Version
Community.general Version
Configuration
$ ansible-config dump --only-changed
OS / Environment
No response
Steps to Reproduce
Run this task and comment out either one of the arguments mentioned in the description
Expected Results
I expect the module to work without specifying both arguments, because they are not marked as "required" in the module documentation and they are not part of the first three examples. (They don't work)
Actual Results
Code of Conduct
The text was updated successfully, but these errors were encountered: