Skip to content

fix: handle negative depTaskCode in DependentItem.fromKey key parsing - #18577

Open
waterWang wants to merge 2 commits into
apache:devfrom
waterWang:fix/dependent-item-negative-dep-task-code
Open

fix: handle negative depTaskCode in DependentItem.fromKey key parsing#18577
waterWang wants to merge 2 commits into
apache:devfrom
waterWang:fix/dependent-item-negative-dep-task-code

Conversation

@waterWang

Copy link
Copy Markdown

What changes were proposed in this pull request?

Fix DependentItem.fromKey() to handle negative depTaskCode values (i.e., -1 for DEPENDENT_ALL_TASK_CODE).

Why are the changes needed?

When a Dependent task is configured with Task Name set to ALL, the UI assigns depTaskCode: -1. The getKey() method produces a key like "2001--1-day-today" (two consecutive hyphens). fromKey() splits on -, yielding 5 parts instead of the expected 4, causing:

java.lang.IllegalArgumentException: Invalid key format
    at DependentItem.fromKey(DependentItem.java:48)
    at DependentTaskTracker.isAllDependentTaskFinished(DependentTaskTracker.java:245)

How were the changes tested?

Unit test covers:

  • Normal key with positive depTaskCode: "2001-123-day-today" → 4 parts
  • Negative depTaskCode: "2001--1-day-today" → 5 parts, correctly parsed as depTaskCode = -1
  • Invalid key format still throws IllegalArgumentException

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): NO
  • Anything that affects deployment: NO
  • The core framework: NO

Documentation

  • Does this pull request introduce a new feature? NO

Closes #18576

When depTaskCode is -1 (DEPENDENT_ALL_TASK_CODE), getKey() produces
a key like "2001--1-day-today". The existing split("-") produces
5 parts instead of the expected 4, causing IllegalArgumentException.
Fix by detecting the 5-part pattern with empty second segment.

Closes apache#18576

@SbloodyS SbloodyS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please follow the pull request template and fill in the form.

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] [Dependent Task] Selecting ALL for a task dependency throws Invalid key format

2 participants