Skip to content

Commit 655f46b

Browse files
committed
Improve error messaging for failures on bulk operation creation
1 parent a170b5a commit 655f46b

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

packages/app/src/cli/services/bulk-operations/execute-bulk-operation.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,13 @@ describe('executeBulkOperation', () => {
204204
query,
205205
})
206206

207-
expect(renderWarning).toHaveBeenCalledWith({
208-
headline: 'Bulk operation errors.',
209-
body: 'query: Invalid query syntax\nunknown: Another error',
207+
expect(renderError).toHaveBeenCalledWith({
208+
headline: 'Error creating bulk operation.',
209+
body: {
210+
list: {
211+
items: ['query: Invalid query syntax', 'Another error'],
212+
},
213+
},
210214
})
211215

212216
expect(renderSuccess).not.toHaveBeenCalled()

packages/app/src/cli/services/bulk-operations/execute-bulk-operation.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,17 @@ export async function executeBulkOperation(input: ExecuteBulkOperationInput): Pr
7474
: await runBulkOperationQuery({adminSession, query, version})
7575

7676
if (bulkOperationResponse?.userErrors?.length) {
77-
const errorMessages = bulkOperationResponse.userErrors
78-
.map(
79-
(error: {field?: string[] | null; message: string}) =>
80-
`${error.field?.join('.') ?? 'unknown'}: ${error.message}`,
81-
)
82-
.join('\n')
83-
renderWarning({
84-
headline: 'Bulk operation errors.',
85-
body: errorMessages,
77+
const errorMessages = bulkOperationResponse.userErrors.map(
78+
(error: {field?: string[] | null; message: string}) =>
79+
`${error.field ? `${error.field.join('.')}: ` : ''}${error.message}`,
80+
)
81+
renderError({
82+
headline: 'Error creating bulk operation.',
83+
body: {
84+
list: {
85+
items: errorMessages,
86+
},
87+
},
8688
})
8789
return
8890
}

0 commit comments

Comments
 (0)