Skip to content

Commit 978d5dc

Browse files
rahulvudutalayakov-feldman
authored andcommitted
DHFPROD-6985: Record History when provenance has a flow that doesn't exist
1 parent b3cd5d3 commit 978d5dc

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/5/entities/entity-search-lib.sjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@ function findFlowAndStepNameFromProvenanceRecords(provenanceRecord, stepNames, s
581581
}
582582
});
583583

584+
if(!flowAndStepNames["flowName"]) {
585+
return flowAndStepNames;
586+
}
587+
584588
for (let currentIndex=0; currentIndex<associatedWith.length-1; currentIndex++) {
585589
if(associatedWith[currentIndex] === flowAndStepNames["flowName"]) {
586590
let artifactTobeRemoved = associatedWith[currentIndex];

marklogic-data-hub/src/test/java/com/marklogic/hub/dataservices/entitySearch/GetRecordTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.marklogic.client.io.Format;
77
import com.marklogic.hub.AbstractHubCoreTest;
88
import com.marklogic.hub.dataservices.EntitySearchService;
9+
import com.marklogic.hub.dataservices.FlowService;
910
import com.marklogic.hub.flow.FlowInputs;
1011
import com.marklogic.hub.flow.FlowRunner;
1112
import com.marklogic.hub.flow.impl.FlowRunnerImpl;
@@ -21,10 +22,12 @@
2122
public class GetRecordTest extends AbstractHubCoreTest {
2223

2324
private EntitySearchService service;
25+
private FlowService flowService;
2426

2527
@BeforeEach
2628
void beforeEach() {
2729
service = EntitySearchService.on(getHubClient().getFinalClient());
30+
flowService = FlowService.on(getHubClient().getFinalClient());
2831
}
2932

3033
@Test
@@ -201,4 +204,25 @@ public void testRecordHistoryTestWithNoProvenanceRecord() {
201204
history = (ArrayNode) response.get("history");
202205
assertEquals(0, history.size());
203206
}
207+
208+
@Test
209+
public void provenanceDataContainsADeletedFlow() {
210+
installProjectInFolder("test-projects/provenance-test");
211+
String path = "test-projects/provenance-test/data/customers";
212+
213+
FlowInputs inputs = new FlowInputs("inline", "1");
214+
inputs.setInputFilePath(readFileFromClasspath(path).getAbsolutePath());
215+
FlowRunner flowRunner = new FlowRunnerImpl(getHubClient());
216+
flowRunner.runFlow(inputs);
217+
flowRunner.awaitCompletion();
218+
219+
// delete a flow
220+
flowService.deleteFlow("inline");
221+
222+
ObjectNode response = (ObjectNode) service.getRecord("/customers/customer1.json");
223+
ArrayNode history = (ArrayNode) response.get("history");
224+
assertEquals(1, history.size());
225+
assertNull(history.get(0).get("flow"));
226+
assertNull(history.get(0).get("step"));
227+
}
204228
}

0 commit comments

Comments
 (0)