Skip to content

Conversation

@njnu-seafish
Copy link
Contributor

Purpose of the pull request

close #17938

Brief change log

throw an exception when the referenced dependent task does not exist

Verify this pull request

This pull request is code cleanup without any test coverage.

(or)

This pull request is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(or)

Pull Request Notice

Pull Request Notice

If your pull request contains incompatible change, you should also add it to docs/docs/en/guide/upgrade/incompatible.md

log.info("The depend item: {} has not completed yet", DependResult.FAILED);
log.info("The dependent result will be {}", DependResult.FAILED);
return DependResult.FAILED;
// Dependent task not found – likely misconfigured task code
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why this should be changed. The current implementation is to put the task in a failed state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why this should be changed. The current implementation is to put the task in a failed state.

Most critically, it will keep failing repeatedly—this is fundamentally different from a legitimate failure of a preceding task—and doing so would obscure the underlying configuration error.

Comment on lines 98 to 102
// Dependent task not found – likely misconfigured task code
log.error("Dependent task definition missing, depTaskCode: {}", item.getDepTaskCode());
throw new RuntimeException(String.format(
"Dependency validation failed: task code %d not found in current workflow. Check dependency config: %s",
item.getDepTaskCode(), item));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should perform validation when the workflow insert/update or ConditionLogicTask start method.
The validation logic should be check if the task is exist at IWorkflowGraph.
In some normal cases, there may be no related task instances here, such as when execution starts from a specific node.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a ConditionLogicTask, dependencies should only reference task codes from preceding tasks in the workflow. Therefore, taskInstance == null should not occur under normal circumstances. If it does, it indicates that a non-existent task code has been configured, and the user should be given a clear error message about this misconfiguration.

Copy link
Contributor Author

@njnu-seafish njnu-seafish Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should perform validation when the workflow insert/update or ConditionLogicTask start method. The validation logic should be check if the task is exist at IWorkflowGraph.

OK. Thanks.

add check in importing workflow case:
#17772

add check in copying workflow case:
#17774

Copy link
Contributor Author

@njnu-seafish njnu-seafish Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instances here, such as when execution starts from a specific node.

If task pre-sh is skipped and execution proceeds directly to the condition task, should the condition task succeed or fail? I still think throwing an exception is more reasonable in this case.

企业微信截图_17701213764286

Copy link
Member

@ruanwenjun ruanwenjun Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition task might contains multiple predecessors, you cannot simple throw exception if one task instance is null here.

@njnu-seafish njnu-seafish requested a review from SbloodyS February 3, 2026 12:26
.isInstanceOf(RuntimeException.class)
.hasMessageContaining("Dependency validation failed")
.hasMessageContaining("task code 999 not found in current workflow");
.hasMessageContaining("task 999 not found or skipped in current workflow");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you run the test? The test shouldn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] [Master&ConditionLogicTask] Throw an exception when the referenced dependent task does not exist in ConditionLogicTask

3 participants