Skip to content

Commit 146c351

Browse files
committed
fix: header must be a string, not array
The header must be a string, not an array. Per the got documentation, `headers` is of type `object<string, string>`. See https://github.com/sindresorhus/got/blob/v14.6.6/documentation/2-options.md#headers Fixes the mis-typing problem introduced in #919 which appears to cause GitLab releases to fail with incorrect `EINVALIDGLTOKEN Invalid GitLab token.` errors
1 parent 20030b9 commit 146c351

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

lib/fail.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default async (pluginConfig, context) => {
3131
const { encodedProjectPath, projectApiUrl } = getProjectContext(context, gitlabUrl, gitlabApiUrl, repositoryUrl);
3232

3333
const apiOptions = {
34-
headers: { [tokenHeader]: gitlabToken },
34+
headers: { tokenHeader: gitlabToken },
3535
retry: {
3636
limit: retryLimit,
3737
statusCodes: retryStatusCodes,

lib/publish.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default async (pluginConfig, context) => {
3030
const encodedGitTag = encodeURIComponent(gitTag);
3131
const apiOptions = {
3232
headers: {
33-
[tokenHeader]: gitlabToken,
33+
tokenHeader: gitlabToken,
3434
},
3535
hooks: {
3636
beforeError: [

lib/success.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default async (pluginConfig, context) => {
2929
} = resolveConfig(pluginConfig, context);
3030
const { projectApiUrl } = getProjectContext(context, gitlabUrl, gitlabApiUrl, repositoryUrl);
3131
const apiOptions = {
32-
headers: { [tokenHeader]: gitlabToken },
32+
headers: { tokenHeader: gitlabToken },
3333
retry: { limit: retryLimit, statusCodes: retryStatusCodes },
3434
};
3535

lib/verify.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ export default async (pluginConfig, context) => {
6666
try {
6767
if (useJobToken) {
6868
logger.log("Using Job Token for authentication. Some functionality may be disabled.");
69-
await got.get(urlJoin(projectApiUrl, "releases"), { headers: { [tokenHeader]: gitlabToken } });
69+
await got.get(urlJoin(projectApiUrl, "releases"), { headers: { tokenHeader: gitlabToken } });
7070
} else {
7171
({
7272
permissions: { project_access: projectAccess, group_access: groupAccess },
7373
} = await got
7474
.get(projectApiUrl, {
75-
headers: { [tokenHeader]: gitlabToken },
75+
headers: { tokenHeader: gitlabToken },
7676
...proxy,
7777
})
7878
.json());

test/helpers/mock-gitlab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ export default function (
2626
const tokenHeader = useJobToken ? "JOB-TOKEN" : "Private-Token";
2727
const token = useJobToken ? env.CI_JOB_TOKEN : gitlabToken;
2828

29-
return nock(urlJoin(gitlabUrl, gitlabApiPathPrefix), { reqheaders: { [tokenHeader]: token } });
29+
return nock(urlJoin(gitlabUrl, gitlabApiPathPrefix), { reqheaders: { tokenHeader: token } });
3030
}

0 commit comments

Comments
 (0)