From 33999f3923874a1db5a7126f07a98ee084453610 Mon Sep 17 00:00:00 2001 From: Ariel Caplan Date: Wed, 8 Jan 2025 14:59:05 +0200 Subject: [PATCH] Skip UID update when in unsafe report mode --- packages/app/src/cli/services/app-context.test.ts | 3 +++ packages/app/src/cli/services/app-context.ts | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/app/src/cli/services/app-context.test.ts b/packages/app/src/cli/services/app-context.test.ts index 1a39e5336a8..ac92dc954d7 100644 --- a/packages/app/src/cli/services/app-context.test.ts +++ b/packages/app/src/cli/services/app-context.test.ts @@ -1,5 +1,6 @@ import {linkedAppContext} from './app-context.js' import {fetchSpecifications} from './generate/fetch-extension-specifications.js' +import {addUidToTomlsIfNecessary} from './app/add-uid-to-extension-toml.js' import link from './app/config/link.js' import {appFromIdentifiers} from './context.js' @@ -259,6 +260,7 @@ describe('linkedAppContext', () => { }) // Then + expect(vi.mocked(addUidToTomlsIfNecessary)).not.toHaveBeenCalled() expect(loadSpy).toHaveBeenCalledWith(expect.any(Object), expect.objectContaining({mode: 'report'})) loadSpy.mockRestore() }) @@ -280,6 +282,7 @@ describe('linkedAppContext', () => { }) // Then + expect(vi.mocked(addUidToTomlsIfNecessary)).toHaveBeenCalled() expect(loadSpy).toHaveBeenCalledWith(expect.any(Object), expect.objectContaining({mode: 'strict'})) loadSpy.mockRestore() }) diff --git a/packages/app/src/cli/services/app-context.ts b/packages/app/src/cli/services/app-context.ts index 8ff5cc2b27e..68f91d4c936 100644 --- a/packages/app/src/cli/services/app-context.ts +++ b/packages/app/src/cli/services/app-context.ts @@ -101,7 +101,12 @@ export async function linkedAppContext({ await logMetadata(remoteApp, organization, forceRelink) // Add UIDs to extension TOML files if using app-management. - await addUidToTomlsIfNecessary(localApp.allExtensions, developerPlatformClient) + // If in unsafe report mode, it is possible the UIDs are not loaded in memory + // even if they are present in the file, so we can't be sure whether or not + // it's necessary. + if (!unsafeReportMode) { + await addUidToTomlsIfNecessary(localApp.allExtensions, developerPlatformClient) + } return {app: localApp, remoteApp, developerPlatformClient, specifications, organization} }