From 1ff8ff2597dd93441e90d35717d29169296d35c3 Mon Sep 17 00:00:00 2001 From: Marcus Olsson Date: Mon, 27 Oct 2025 18:01:15 +0100 Subject: [PATCH 1/3] Ensures options object is initialized Guarantees that the options object is initialized to prevent potential errors when calling cloud functions. This ensures smooth execution even when no options are explicitly provided. --- src/Cloud.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Cloud.ts b/src/Cloud.ts index c8fd781ad..b5e7470b0 100644 --- a/src/Cloud.ts +++ b/src/Cloud.ts @@ -46,6 +46,7 @@ export function run< T extends (param: { [P in keyof Parameters[0]]: Parameters[0][P] }) => any, >(name: string, data: Parameters[0], options?: RequestOptions): Promise>; export function run(name: string, data?: any, options?: RequestOptions): Promise { + options = options || {}; if (typeof name !== 'string' || name.length === 0) { throw new TypeError('Cloud function name must be a string.'); } From 825ee1a07b63e15c9d4c2ad437af5e001fa27060 Mon Sep 17 00:00:00 2001 From: Marcus Olsson Date: Mon, 27 Oct 2025 18:47:18 +0100 Subject: [PATCH 2/3] Improves Cloud.run options validation Updates the validation logic for the options parameter in the Cloud.run function. Allows null as a valid options value, and removes null from the invalid options list. This change ensures the function correctly handles different input scenarios. --- src/__tests__/Cloud-test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/__tests__/Cloud-test.js b/src/__tests__/Cloud-test.js index dba85b255..8ad96bcb4 100644 --- a/src/__tests__/Cloud-test.js +++ b/src/__tests__/Cloud-test.js @@ -357,8 +357,8 @@ describe('CloudController', () => { expect(options.useMasterKey).toBe(false); }); - it('run passes with empty options', () => { - const values = [undefined, {}]; + it('run passes with undefined, null or empty options', () => { + const values = [undefined, null, {}]; const mockRun = jest.fn(); mockRun.mockReturnValue(Promise.resolve({ result: {} })); @@ -377,7 +377,7 @@ describe('CloudController', () => { }); it('run throws with invalid options', () => { - const values = [null, []]; + const values = [[]]; for (const value of values) { expect(() => Cloud.run('myfunction', {}, value)).toThrow(); } From 77486bbb144c72474d6f4c87fdf6f05c6d4b6be7 Mon Sep 17 00:00:00 2001 From: Marcus Olsson Date: Mon, 27 Oct 2025 18:56:12 +0100 Subject: [PATCH 3/3] Update Cloud.ts Removed trailing space Signed-off-by: Marcus Olsson --- src/Cloud.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cloud.ts b/src/Cloud.ts index b5e7470b0..b9b785708 100644 --- a/src/Cloud.ts +++ b/src/Cloud.ts @@ -46,7 +46,7 @@ export function run< T extends (param: { [P in keyof Parameters[0]]: Parameters[0][P] }) => any, >(name: string, data: Parameters[0], options?: RequestOptions): Promise>; export function run(name: string, data?: any, options?: RequestOptions): Promise { - options = options || {}; + options = options || {}; if (typeof name !== 'string' || name.length === 0) { throw new TypeError('Cloud function name must be a string.'); }