From 92e99b85412bfdf77afb30e6acbf85ad31688e30 Mon Sep 17 00:00:00 2001 From: mduda Date: Tue, 24 Mar 2026 12:10:48 +0100 Subject: [PATCH] fix: [DPS-41958] - Destination Form: omit empty tls_hostname from destination payload --- .../pr-13524-fixed-1774351558003.md | 5 ++ .../features/Delivery/deliveryUtils.test.ts | 50 +++++++++++++++++++ .../src/features/Delivery/deliveryUtils.ts | 10 +++- 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 packages/manager/.changeset/pr-13524-fixed-1774351558003.md diff --git a/packages/manager/.changeset/pr-13524-fixed-1774351558003.md b/packages/manager/.changeset/pr-13524-fixed-1774351558003.md new file mode 100644 index 00000000000..899f86a96c6 --- /dev/null +++ b/packages/manager/.changeset/pr-13524-fixed-1774351558003.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Fixed +--- + +Destination Form: omit the tls_hostname field from the request if it is empty or contains only whitespace ([#13524](https://github.com/linode/manager/pull/13524)) diff --git a/packages/manager/src/features/Delivery/deliveryUtils.test.ts b/packages/manager/src/features/Delivery/deliveryUtils.test.ts index 17f56ab9639..58648e0b6c5 100644 --- a/packages/manager/src/features/Delivery/deliveryUtils.test.ts +++ b/packages/manager/src/features/Delivery/deliveryUtils.test.ts @@ -288,6 +288,56 @@ describe('delivery utils functions', () => { expect(result.content_type).toBeUndefined(); expect(result.client_certificate_details).toBeUndefined(); }); + + it('should omit tls_hostname from client_certificate_details when it is an empty string', () => { + const details: CustomHTTPSDetailsExtended = { + ...baseCustomHTTPSDetails, + client_certificate_details: { + client_ca_certificate: 'ca-cert', + client_certificate: 'cert', + client_private_key: 'key', + tls_hostname: '', + }, + }; + + const result = getDestinationPayloadDetails( + details, + destinationType.CustomHttps + ) as CustomHTTPSDetailsExtended; + + expect(result.client_certificate_details).toBeDefined(); + expect(result.client_certificate_details?.tls_hostname).toBeUndefined(); + expect(result.client_certificate_details).toEqual({ + client_ca_certificate: 'ca-cert', + client_certificate: 'cert', + client_private_key: 'key', + }); + }); + + it('should omit tls_hostname from client_certificate_details when it is whitespace', () => { + const details: CustomHTTPSDetailsExtended = { + ...baseCustomHTTPSDetails, + client_certificate_details: { + client_ca_certificate: 'ca-cert', + client_certificate: 'cert', + client_private_key: 'key', + tls_hostname: ' ', + }, + }; + + const result = getDestinationPayloadDetails( + details, + destinationType.CustomHttps + ) as CustomHTTPSDetailsExtended; + + expect(result.client_certificate_details).toBeDefined(); + expect(result.client_certificate_details?.tls_hostname).toBeUndefined(); + expect(result.client_certificate_details).toEqual({ + client_ca_certificate: 'ca-cert', + client_certificate: 'cert', + client_private_key: 'key', + }); + }); }); }); }); diff --git a/packages/manager/src/features/Delivery/deliveryUtils.ts b/packages/manager/src/features/Delivery/deliveryUtils.ts index b722f50207d..91c0be442dd 100644 --- a/packages/manager/src/features/Delivery/deliveryUtils.ts +++ b/packages/manager/src/features/Delivery/deliveryUtils.ts @@ -110,6 +110,7 @@ export const getDestinationPayloadDetails = ( if (type === destinationType.CustomHttps) { const propsToRemove: any[] = []; const customHTTPSDetails = details as CustomHTTPSDetailsExtended; + let finalCustomHTTPSDetails = customHTTPSDetails; if (!customHTTPSDetails.content_type) { propsToRemove.push('content_type'); @@ -125,15 +126,22 @@ export const getDestinationPayloadDetails = ( if (shouldRemoveCertDetails) { propsToRemove.push('client_certificate_details'); + } else if (!certDetails.tls_hostname?.trim()) { + finalCustomHTTPSDetails = { + ...customHTTPSDetails, + client_certificate_details: omitProps(certDetails, ['tls_hostname']), + }; } } if (propsToRemove.length > 0) { return omitProps( - customHTTPSDetails, + finalCustomHTTPSDetails, propsToRemove ) as CustomHTTPSDetailsExtended; } + + return finalCustomHTTPSDetails; } else if ('path' in details && details.path === '') { return omitProps(details, ['path']); }