Closed Dravere closed 1 month ago
Description
Protecting tags generates a bad request error as the typing on the function is wrong.
Steps to reproduce
const gitlabApi = new Gitlab({ host: 'https://some.gitlab.host', token: tokenValue }) await gitlabApi.ProtectedTags.protect(projectId, "v*", { allowedToCreate: { groupId: GROUP_ID }, createAccessLevel: AccessLevel.MAINTAINER })
This is accepted by the typing but will throw a GitBeaker exception, since the server will response with a bad request.
Expected behaviour
It should create the protected tag.
Actual behaviour
The server responses with a HTTP status code 400 bad request.
Possible fixes
I can get it to work with this workaround:
const gitlabApi = new Gitlab({ host: 'https://some.gitlab.host', token: tokenValue }) await gitlabApi.ProtectedTags.protect(projectId, "v*", { allowedToCreate: [ { groupId: GROUP_ID } ] as unknown as ProtectedTagAccessLevelEntity, createAccessLevel: AccessLevel.MAINTAINER })
To me it seems the error is located on this line: https://github.com/jdalrymple/gitbeaker/blob/main/packages/core/src/resources/ProtectedTags.ts#L53
Instead of accepting a single entity it should accept an array of these entities:
allowedToCreate?: ProtectedTagAccessLevelEntity[];
The same will then also be true for this line (protect function instead of create): https://github.com/jdalrymple/gitbeaker/blob/main/packages/core/src/resources/ProtectedTags.ts#L79
protect
create
The GitLab documentation also clearly states this has to be a list of entities: https://docs.gitlab.com/ee/api/protected_tags.html#protect-repository-tags
Also under 16.11: https://archives.docs.gitlab.com/16.11/ee/api/protected_tags.html#protect-repository-tags
Checklist
:rocket: Issue was released in 40.6.0 :rocket:
40.6.0
Description
Protecting tags generates a bad request error as the typing on the function is wrong.
Steps to reproduce
This is accepted by the typing but will throw a GitBeaker exception, since the server will response with a bad request.
Expected behaviour
It should create the protected tag.
Actual behaviour
The server responses with a HTTP status code 400 bad request.
Possible fixes
I can get it to work with this workaround:
To me it seems the error is located on this line: https://github.com/jdalrymple/gitbeaker/blob/main/packages/core/src/resources/ProtectedTags.ts#L53
Instead of accepting a single entity it should accept an array of these entities:
The same will then also be true for this line (
protect
function instead ofcreate
): https://github.com/jdalrymple/gitbeaker/blob/main/packages/core/src/resources/ProtectedTags.ts#L79The GitLab documentation also clearly states this has to be a list of entities: https://docs.gitlab.com/ee/api/protected_tags.html#protect-repository-tags
Also under 16.11: https://archives.docs.gitlab.com/16.11/ee/api/protected_tags.html#protect-repository-tags
Checklist