From 6c118dd093eea6f96004bb8ee3a48a8391dcdb8d Mon Sep 17 00:00:00 2001 From: Manuel Stein Date: Sat, 23 Jul 2022 18:34:57 +0300 Subject: [PATCH] wrap aws-sdk errors - (prettier update) there are http errors with no message from aws-sdk, so the error is wrapped to conform to the @backstage/errors assertError checks Signed-off-by: Manuel Stein --- .changeset/loud-panthers-arrive.md | 2 +- plugins/techdocs-node/src/stages/publish/awsS3.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.changeset/loud-panthers-arrive.md b/.changeset/loud-panthers-arrive.md index 76e6812b5b..a8c69cdc76 100644 --- a/.changeset/loud-panthers-arrive.md +++ b/.changeset/loud-panthers-arrive.md @@ -4,4 +4,4 @@ Fix AWS S3 404 NotFound error -When reading an object from the S3 bucket through a stream, the aws-sdk getObject() API may throw a 404 NotFound Error with no error message or, in fact, any sort of HTTP-layer error responses. These fail the @backstage/error's assertError() checks, so they must be wrapped. The test for this case was also updated to match the wrapped error message. \ No newline at end of file +When reading an object from the S3 bucket through a stream, the aws-sdk getObject() API may throw a 404 NotFound Error with no error message or, in fact, any sort of HTTP-layer error responses. These fail the @backstage/error's assertError() checks, so they must be wrapped. The test for this case was also updated to match the wrapped error message. diff --git a/plugins/techdocs-node/src/stages/publish/awsS3.ts b/plugins/techdocs-node/src/stages/publish/awsS3.ts index d3456b7f21..12940e0117 100644 --- a/plugins/techdocs-node/src/stages/publish/awsS3.ts +++ b/plugins/techdocs-node/src/stages/publish/awsS3.ts @@ -49,7 +49,9 @@ const streamToBuffer = (stream: Readable): Promise => { try { const chunks: any[] = []; stream.on('data', chunk => chunks.push(chunk)); - stream.on('error', (e: Error) => reject(new ForwardedError('Unable to read stream', e))); + stream.on('error', (e: Error) => + reject(new ForwardedError('Unable to read stream', e)), + ); stream.on('end', () => resolve(Buffer.concat(chunks))); } catch (e) { throw new ForwardedError('Unable to parse the response data', e);