-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
Sometimes, the stager function receives a message to download a file that should exist but doesn' t. If we throw an error, the message will be sent to the DLQ, to be processed again in a re-drive. But given that this file will probably never be available, the re-drives will also fail, and we'll never be able to get rid of the message in the DLQ. Instead, we ignore this version by returning silently. NPM seems to occasionally drop tarballs on the floor when a new package version is released, which you can notice on the download stats because the package has been downloaded `0` times. So far we've seen that happen for: * [@pepperize/cdk-vpc@0.0.785](https://www.npmjs.com/package/@pepperize/cdk-vpc/v/0.0.785?activeTab=versions) * [@aws-sdk/credential-provider-http@3.422.0](https://www.npmjs.com/package/@aws-sdk/credential-provider-http/v/3.422.0?activeTab=versions) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --------- Signed-off-by: github-actions <github-actions@github.com> Co-authored-by: github-actions <github-actions@github.com>
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Context } from 'aws-lambda'; | ||
import * as AWS from 'aws-sdk'; | ||
import * as AWSMock from 'aws-sdk-mock'; | ||
import * as nock from 'nock'; | ||
import { | ||
ENV_DENY_LIST_BUCKET_NAME, | ||
ENV_DENY_LIST_OBJECT_KEY, | ||
} from '../../../backend/deny-list/constants'; | ||
import { | ||
handler, | ||
PackageVersion, | ||
} from '../../../package-sources/npmjs/stage-and-notify.lambda'; | ||
|
||
const MOCK_DENY_LIST_BUCKET = 'deny-list-bucket-name'; | ||
const MOCK_DENY_LIST_OBJECT = 'my-deny-list.json'; | ||
|
||
type Response<T> = (err: AWS.AWSError | null, data?: T) => void; | ||
|
||
beforeEach(() => { | ||
process.env.BUCKET_NAME = 'foo'; | ||
process.env.QUEUE_URL = 'bar'; | ||
process.env[ENV_DENY_LIST_BUCKET_NAME] = MOCK_DENY_LIST_BUCKET; | ||
process.env[ENV_DENY_LIST_OBJECT_KEY] = MOCK_DENY_LIST_OBJECT; | ||
}); | ||
|
||
afterEach(() => { | ||
process.env.BUCKET_NAME = undefined; | ||
process.env.QUEUE_URL = undefined; | ||
delete process.env[ENV_DENY_LIST_BUCKET_NAME]; | ||
delete process.env[ENV_DENY_LIST_OBJECT_KEY]; | ||
}); | ||
|
||
test('ignores 404', async () => { | ||
const basePath = 'https://registry.npmjs.org'; | ||
const uri = '/@pepperize/cdk-vpc/-/cdk-vpc-0.0.785.tgz'; | ||
|
||
AWSMock.mock( | ||
'S3', | ||
'getObject', | ||
(_req: AWS.S3.GetObjectRequest, cb: Response<AWS.S3.GetObjectOutput>) => { | ||
cb(null, { Body: JSON.stringify({}) }); | ||
} | ||
); | ||
|
||
nock(basePath).get(uri).reply(404); | ||
|
||
const event: PackageVersion = { | ||
tarballUrl: `${basePath}${uri}`, | ||
integrity: '09d37ec93c5518bf4842ac8e381a5c06452500e5', | ||
modified: '2023-09-22T15:48:10.381Z', | ||
name: '@pepper/cdk-vpc', | ||
seq: '26437963', | ||
version: '0.0.785', | ||
}; | ||
|
||
const context: Context = {} as any; | ||
|
||
await expect(handler(event, context)).resolves.toBe(undefined); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.