From 913eb96ab04fdf54fc14af91f9668222af52598a Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 8 Nov 2022 11:34:16 +0000 Subject: [PATCH] Fixing an issue which was alerting, x-amz-meta-fieldname contains an invalid value, this error isn't really documented, but comes from if a metadata tag is sent up with nullish, or a non-string type. Fixing this in the core library, removing an invalid inputs. --- packages/backend-core/src/objectStore/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/backend-core/src/objectStore/index.ts b/packages/backend-core/src/objectStore/index.ts index 8453c9aee6..15b01795ab 100644 --- a/packages/backend-core/src/objectStore/index.ts +++ b/packages/backend-core/src/objectStore/index.ts @@ -163,6 +163,12 @@ export const upload = async ({ ContentType: type || CONTENT_TYPE_MAP[extension.toLowerCase()], } if (metadata) { + // remove any nullish keys from the metadata object, as these may be considered invalid + for (let key of Object.keys(metadata)) { + if (!metadata[key] || typeof metadata[key] !== "string") { + delete metadata[key] + } + } config.Metadata = metadata } return objectStore.upload(config).promise()