Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Fix NPE for verify and repair if workflow not found #3598

Merged
merged 2 commits into from
May 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package com.netflix.conductor.core.reconciliation;

import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Predicate;

Expand All @@ -24,6 +25,7 @@
import com.netflix.conductor.annotations.VisibleForTesting;
import com.netflix.conductor.common.metadata.tasks.TaskType;
import com.netflix.conductor.core.config.ConductorProperties;
import com.netflix.conductor.core.exception.NotFoundException;
import com.netflix.conductor.core.execution.tasks.SystemTaskRegistry;
import com.netflix.conductor.core.execution.tasks.WorkflowSystemTask;
import com.netflix.conductor.core.utils.QueueUtils;
Expand Down Expand Up @@ -101,7 +103,12 @@ public boolean verifyAndRepairWorkflow(String workflowId, boolean includeTasks)

/** Verify and repair tasks in a workflow. */
public void verifyAndRepairWorkflowTasks(String workflowId) {
WorkflowModel workflow = executionDAO.getWorkflow(workflowId, true);
WorkflowModel workflow =
Optional.ofNullable(executionDAO.getWorkflow(workflowId, true))
.orElseThrow(
() ->
new NotFoundException(
"Could not find workflow: " + workflowId));
workflow.getTasks().forEach(this::verifyAndRepairTask);
// repair the parent workflow if needed
verifyAndRepairWorkflow(workflow.getParentWorkflowId());
Expand Down