Skip to content

Commit 9d69289

Browse files
authored
fix: missing file for m365 step after pipe transfer (#854)
## Problem Missing file error is not caught properly after pipe is transferred, this occurs if the m365 excel file is not manually transferred from the old owner to the new owner (and the new owner clicks on pipe transfer settings) ## Solution Catch the error and warn with the logger + return instructions for missing file ## Tests - Check that after pipe transfer, new owner clicks into the settings and no error shows anymore (instead the instruction shows) <img width="586" alt="image" src="https://github.com/user-attachments/assets/5a3cb65a-7c08-432e-b1fa-847297a34c29" />
2 parents f557676 + 23adc5e commit 9d69289

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

packages/backend/src/apps/m365-excel/common/get-transfer-details.ts

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { IGlobalVariable, ITransferDetails } from '@plumber/types'
22

3+
import get from 'lodash.get'
4+
35
import { getM365TenantInfo } from '@/config/app-env-vars/m365'
46
import { getEmptyConnectionDetails } from '@/helpers/get-default-transfer-details'
7+
import logger from '@/helpers/logger'
58

69
import { AuthData } from './auth-data'
710

@@ -41,22 +44,38 @@ async function getTransferDetails(
4144

4245
// TODO (mal/WL): query takes around 0.5s, build cache if necessary
4346
const tenant = getM365TenantInfo(authData.tenantKey)
44-
const results = await $.http.get<{ name: string }>(
45-
`/v1.0/sites/${tenant.sharePointSiteId}/drive/items/${fileId}?$select=name`,
46-
)
47-
48-
if (!results.data.name) {
47+
try {
48+
const results = await $.http.get<{ name: string }>(
49+
`/v1.0/sites/${tenant.sharePointSiteId}/drive/items/${fileId}?$select=name`,
50+
)
4951
return {
5052
position: $.step.position,
5153
appName: $.app.name,
52-
instructions: 'No M365 file is found',
54+
connectionName: results.data.name,
55+
}
56+
} catch (error) {
57+
const errorCode = get(error, 'details.error.code', '')
58+
logger.warn('Error with M365 excel before pipe transfer', {
59+
event: 'm365-excel-pipe-transfer',
60+
errorCode,
61+
error,
62+
flowId: $.flow.id,
63+
stepId: $.step.id,
64+
})
65+
66+
if (errorCode === 'itemNotFound') {
67+
return {
68+
position: $.step.position,
69+
appName: $.app.name,
70+
instructions: 'M365 file cannot be found in your folder',
71+
}
5372
}
54-
}
5573

56-
return {
57-
position: $.step.position,
58-
appName: $.app.name,
59-
connectionName: results.data.name,
74+
return {
75+
position: $.step.position,
76+
appName: $.app.name,
77+
instructions: 'Unknown error with M365 excel',
78+
}
6079
}
6180
}
6281

0 commit comments

Comments
 (0)