Skip to content

Commit a18e716

Browse files
fix(restore-indices): log error instead of silent failure (#15070)
1 parent 61f9dd9 commit a18e716

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/restoreindices/SendMAEStep.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ public Function<UpgradeContext, UpgradeStepResult> executable() {
224224
context.report().addLine("End of data.");
225225
break;
226226
} else {
227+
log.error("Failure processing restore indices batch.", e);
227228
return new DefaultUpgradeStepResult(id(), DataHubUpgradeState.FAILED);
228229
}
229230
}

datahub-upgrade/src/test/java/com/linkedin/datahub/upgrade/restoreindices/SendMAEStepTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,4 +424,27 @@ public void testExecutableWithCreateDefaultAspects() {
424424
RestoreIndicesArgs capturedArgs = argsCaptor.getValue();
425425
assertTrue(capturedArgs.createDefaultAspects);
426426
}
427+
428+
@Test
429+
public void testExecutableWithNullResultFromFuture() {
430+
// Insert test data to trigger processing
431+
insertTestRows(5, null);
432+
433+
// Enable URN-based pagination to hit log.error in URN-based pagination path
434+
parsedArgs.put(RestoreIndices.URN_BASED_PAGINATION_ARG_NAME, Optional.of("true"));
435+
436+
// Mock the entity service to throw an exception (not NoSuchElementException)
437+
when(mockEntityService.restoreIndices(eq(mockOpContext), any(RestoreIndicesArgs.class), any()))
438+
.thenThrow(new RuntimeException("Test exception"));
439+
440+
// Execute
441+
UpgradeStepResult result = sendMAEStep.executable().apply(mockContext);
442+
443+
// Verify failure when exception is thrown in URN-based pagination
444+
// This tests the log.error in the URN-based pagination path
445+
assertTrue(result instanceof DefaultUpgradeStepResult);
446+
assertEquals(result.result(), DataHubUpgradeState.FAILED);
447+
assertEquals(result.stepId(), sendMAEStep.id());
448+
assertEquals(result.action(), UpgradeStepResult.Action.CONTINUE);
449+
}
427450
}

0 commit comments

Comments
 (0)