Skip to content

Commit

Permalink
Merge pull request #5171 from Shopify/skip-uid-update-on-report-mode
Browse files Browse the repository at this point in the history
[Fix] Skip UID update when in unsafe report mode
  • Loading branch information
amcaplan authored Jan 8, 2025
2 parents 3a658c7 + 33999f3 commit ed55fc7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/app/src/cli/services/app-context.test.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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()
})
Expand All @@ -280,6 +282,7 @@ describe('linkedAppContext', () => {
})

// Then
expect(vi.mocked(addUidToTomlsIfNecessary)).toHaveBeenCalled()
expect(loadSpy).toHaveBeenCalledWith(expect.any(Object), expect.objectContaining({mode: 'strict'}))
loadSpy.mockRestore()
})
Expand Down
7 changes: 6 additions & 1 deletion packages/app/src/cli/services/app-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down

0 comments on commit ed55fc7

Please sign in to comment.