Skip to content

Conversation

@njnu-seafish
Copy link
Contributor

@njnu-seafish njnu-seafish commented Dec 23, 2025

Purpose of the pull request

close #17820

Brief change log

Add query projectUser logic to avoid NullPointerException

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

@njnu-seafish njnu-seafish changed the title [Fix-17817][Master]Add query projectUser logic to avoid NullPointerException [Fix-17817][Master]Add logic to query projectUser in order to avoid NullPointerException when task or workflow timeout alerts are configured. Dec 23, 2025
Comment on lines 249 to 252
// A null warningGroupId indicates that the user has explicitly configured a "no-alert" policy.
if (workflowInstance.getWarningGroupId() == null) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// A null warningGroupId indicates that the user has explicitly configured a "no-alert" policy.
if (workflowInstance.getWarningGroupId() == null) {
return;
}

Don't add this kind of code, we needn't check at here, the method name is not sendTaskTimeoutAlertIfNeeded

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't add this kind of code, we needn't check at here, the method name is not sendTaskTimeoutAlertIfNeeded

If the user chooses not to send alerts, workflowInstance.getWarningGroupId() will be null, which will cause a NullPointerException.

Copy link
Member

@ruanwenjun ruanwenjun Dec 24, 2025

Choose a reason for hiding this comment

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

If the user chooses not to send alerts, can this method be called? We need to filter at the upper layer.
If the sendTaskTimeoutAlert method ultimately doesn't send an alert, that would be highly unusual.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the user chooses not to send alerts, can this method be called? We need to filter at the upper layer. If the sendTaskTimeoutAlert method ultimately doesn't send an alert, that would be highly unusual.

OK,will handle in TaskTimeoutLifecycleEventHandler

public void sendTaskTimeoutAlert(WorkflowInstance workflowInstance,
TaskInstance taskInstance,
ProjectUser projectUser) {
assert projectUser != null;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert projectUser != null;
if(projectUser == null) {
throw IlleganArguementException("project user is null");
}

assert will do nothing if the jvm doesn't enable it.

And I don't think we need to check the project user here, since this shouldn't affect the alert, alert only need to take care about alert plugin, if the project user is null, it only affects the alert content.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if(projectUser == null) {
throw IlleganArguementException("project user is null");
}

The DS project contains a large number of assert statements—I assumed they were recommended for use.
If we don't check in advance, a NullPointerException (NPE) will occur.

Copy link
Member

Choose a reason for hiding this comment

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

Only a few historical codes contain assert statements.

The proper fix is to set the property to empty, rather than ignore the alert.

@Zzih96
Copy link
Contributor

Zzih96 commented Dec 24, 2025

It seems the issue of the missing workflow timeout alarm function has not been resolved.

@njnu-seafish
Copy link
Contributor Author

It seems the issue of the missing workflow timeout alarm function has not been resolved.

In our environment, the issue has already been resolved—both task timeout alerts and workflow timeout alerts were occurring.

NPL exceptions mainly occur in the following two places:
1, projectUser == null
2, workflowInstance.getWarningGroupId() == null

@njnu-seafish
Copy link
Contributor Author

It seems the issue of the missing workflow timeout alarm function has not been resolved.

Of course, we’d be very happy to see any better solutions you might have!

@Zzih96
Copy link
Contributor

Zzih96 commented Dec 24, 2025

workflowInstance.getWarningGroupId()

What version are you using?

TaskInstance taskInstance,
ProjectUser projectUser) {
TaskInstance taskInstance) {
ProjectUser projectUser = projectMapper.queryProjectWithUserByWorkflowInstanceId(workflowInstance.getId());
Copy link
Member

Choose a reason for hiding this comment

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

It's better to use ProjectDao instead of directly use ProjectMapper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's better to use ProjectDao instead of directly use ProjectMapper.

ok, it's better

@SbloodyS SbloodyS changed the title [Fix-17817][Master]Add logic to query projectUser in order to avoid NullPointerException when task or workflow timeout alerts are configured. [Fix-17817][Master] Fix task timeout alerts failed Dec 24, 2025
@SbloodyS SbloodyS added the bug Something isn't working label Dec 24, 2025
@SbloodyS SbloodyS added this to the 3.4.0 milestone Dec 24, 2025
@njnu-seafish njnu-seafish changed the title [Fix-17817][Master] Fix task timeout alerts failed [Fix-17820][Master] Fix task timeout alerts failed Dec 24, 2025
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
13.0% Coverage on New Code (required ≥ 60%)

See analysis details on SonarQube Cloud

@ruanwenjun
Copy link
Member

Please add IT case, if you cannot add IT case ,please at least raise a new issue to supple IT case.

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] A NullPointerException will occur when task timeout alerts are configured.

4 participants