tool-cache downloadTool does not support relative redirects
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- networking
Research direction
Start with packages/tool-cache/tests/tool-cache.test.ts and add or run the provided relative-redirect case to reproduce the failure. Then trace the redirect handling in the @actions/http-client package; done means the test downloads the 35-byte file successfully and the repository tests pass.
Written by the indexing model from the issue text.
Description
Describe the bug
If tc.downloadTool is used with a url that returns a relative redirect then the function fails with the error: TypeError: Invalid URL as it attempts to parse the relative url as an absolute url.
To Reproduce
Steps to reproduce the behavior:
- Apply this patch with a test to check the behaviour:
diff --git a/packages/tool-cache/__tests__/tool-cache.test.ts b/packages/tool-cache/__tests__/tool-cache.test.ts
index 4712ab5f..c4329275 100644
--- a/packages/tool-cache/__tests__/tool-cache.test.ts
+++ b/packages/tool-cache/__tests__/tool-cache.test.ts
@@ -111,6 +111,22 @@ describe('@actions/tool-cache', function () {
expect(fs.statSync(downPath).size).toBe(35)
})
+ it('downloads a 35 byte file after a relative redirect', async () => {
+ nock('http://example.com')
+ .persist()
+ .get('/relative-redirect')
+ .reply(303, undefined, {
+ location: 'bytes/35'
+ })
+
+ const downPath: string = await tc.downloadTool(
+ 'http://example.com/relative-redirect'
+ )
+
+ expect(fs.existsSync(downPath)).toBeTruthy()
+ expect(fs.statSync(downPath).size).toBe(35)
+ })
+
it('handles error from response message stream', async () => {
nock('http://example.com')
.persist()
- Run the repository tests and view the
TypeError: Invalid URLfailure.
Expected behavior
The relative location should be resolved with the current url as the base instead of as an absolute url.
Additional context
The support for relative redirects is missing in the @actions/http-client package.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from actions/toolkit
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
properly join URLs Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100