[Improvement-17942][API&UI]Add startParams validation logic in both the frontend and backend.#17956
[Improvement-17942][API&UI]Add startParams validation logic in both the frontend and backend.#17956njnu-seafish wants to merge 21 commits intoapache:devfrom
Conversation
| // UI configuration state from form management hook | ||
| ...startState.startForm, | ||
| // Business data injected from modal operations hook | ||
| startParamsList: variables.startParamsList |
There was a problem hiding this comment.
| // UI configuration state from form management hook | |
| ...startState.startForm, | |
| // Business data injected from modal operations hook | |
| startParamsList: variables.startParamsList | |
| ...startState.startForm, | |
| startParamsList: variables.startParamsList |
There was a problem hiding this comment.
// UI configuration state from form management hook
ok
| // null key | ||
| if (StringUtils.isEmpty(param.getProp())) { | ||
| throw new ServiceException("Parameter key cannot be empty"); | ||
| } | ||
|
|
||
| String key = param.getProp().trim(); | ||
| // duplicate keys | ||
| if (keys.contains(key)) { | ||
| throw new ServiceException("Duplicate parameter key: " + key); | ||
| } | ||
| keys.add(key); | ||
|
|
||
| // IN-type params require a non-empty value | ||
| if (Direct.IN.equals(param.getDirect()) && StringUtils.isEmpty(param.getValue())) { | ||
| throw new ServiceException("IN parameter value cannot be empty for key: " + key); | ||
| } |
There was a problem hiding this comment.
| // null key | |
| if (StringUtils.isEmpty(param.getProp())) { | |
| throw new ServiceException("Parameter key cannot be empty"); | |
| } | |
| String key = param.getProp().trim(); | |
| // duplicate keys | |
| if (keys.contains(key)) { | |
| throw new ServiceException("Duplicate parameter key: " + key); | |
| } | |
| keys.add(key); | |
| // IN-type params require a non-empty value | |
| if (Direct.IN.equals(param.getDirect()) && StringUtils.isEmpty(param.getValue())) { | |
| throw new ServiceException("IN parameter value cannot be empty for key: " + key); | |
| } | |
| if (StringUtils.isEmpty(param.getProp())) { | |
| throw new ServiceException("Parameter key cannot be empty"); | |
| } | |
| String key = param.getProp().trim(); | |
| if (keys.contains(key)) { | |
| throw new ServiceException("Duplicate parameter key: " + key); | |
| } | |
| if (Direct.IN.equals(param.getDirect()) && StringUtils.isEmpty(param.getValue())) { | |
| throw new ServiceException("IN parameter value cannot be empty for key: " + key); | |
| } | |
| keys.add(key); |
| if (startParamList == null || startParamList.isEmpty()) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
| if (startParamList == null || startParamList.isEmpty()) { | |
| return; | |
| } | |
| if (CollectionUtils.isEmpty(startParamList)) { | |
| return; | |
| } |
There was a problem hiding this comment.
if (CollectionUtils.isEmpty(startParamList)) {
good
|
Hey @ruanwenjun @SbloodyS, whenever you have time, would you mind reviewing this fix to see if it looks reasonable? Really thanks a lot! |
| return triggerWorkflowDTO; | ||
| } | ||
|
|
||
| private void validateStartParamList(List<Property> startParamList) { |
There was a problem hiding this comment.
You should do the validation work at TriggerWorkflowDTOValidator.
There was a problem hiding this comment.
You should do the validation work at
TriggerWorkflowDTOValidator.
good idea
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import com.alibaba.druid.util.StringUtils; |
There was a problem hiding this comment.
sorry, I made a mistake.
|
Hey @ruanwenjun @SbloodyS, whenever you have time, would you mind reviewing this fix? Really thanks a lot! |
|



Purpose of the pull request
close #17942
Brief change log
Add startParams validation logic in both the frontend and backend.
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