You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Arrays are not sent correctly due to not using [] after variable name #1419
Thanks for that @JohnVillalovos! I thought it might be something to do with arrays.
So this means we might have to manually maintain a lot of custom _types fields 🤔 I'm just not 100% sure that really all GitLab API endpoints take form-encoded arrays in addition to comma-delimited strings. See this upstream from a while ago (probably outdated now) https://gitlab.com/gitlab-org/gitlab-foss/-/issues/48007. I think it's time I added some parametrized integration tests for this.
Agreed, if gitlab handles it then this should do for now. I also just did a quick grep and seems like all GET params that are arrays get massaged with the above from strings :) If it's a problem later we can convert to an array with urlencode.
Activity
nejch commentedon Apr 27, 2021
Thanks for that @JohnVillalovos! I thought it might be something to do with arrays.
So this means we might have to manually maintain a lot of custom
_typesfields 🤔 I'm just not 100% sure that really all GitLab API endpoints take form-encoded arrays in addition to comma-delimited strings. See this upstream from a while ago (probably outdated now) https://gitlab.com/gitlab-org/gitlab-foss/-/issues/48007. I think it's time I added some parametrized integration tests for this.JohnVillalovos commentedon Apr 27, 2021
@nejch
On the good news, it seems like an
arraycan be sent as a comma-delimited string. (https://gitlab.com/gitlab-org/gitlab/-/blob/5ecf69de438d221ed25f5f86756721f5f7b7b389/lib/api/validations/types/comma_separated_to_array.rb#L13)This is probably the easiest way to make it work with using the
types.ListAtribute. So theniids=[1,2,3]will becomeiids=1,2,3in the HTTP request.More complicated would be to take a value like:
iids=[1, 2, 3]and then convert that intoiids[]=1&iids[]=2&iids[]=3in the HTTP request.Thoughts?
nejch commentedon Apr 27, 2021
Agreed, if gitlab handles it then this should do for now. I also just did a quick grep and seems like all
GETparams that are arrays get massaged with the above from strings :) If it's a problem later we can convert to an array with urlencode.Edit: On second thought, there are also cases where this probably won't help, see e.g. https://gitlab.com/gitlab-org/gitlab/-/blob/5889dadb55c8d7b6a4c6a378914769eea16717d1/lib/api/jobs.rb#L16-29. So #806 won't be fixed by this.