Skip to content

[Improvement-18224][API] Migrate TaskGroupService and ExecutorServiceforceStartTaskInstance to typed returns#18233

Open
ruanwenjun wants to merge 1 commit intoapache:devfrom
ruanwenjun:chore/api-task-group-executor-typed-returns
Open

[Improvement-18224][API] Migrate TaskGroupService and ExecutorServiceforceStartTaskInstance to typed returns#18233
ruanwenjun wants to merge 1 commit intoapache:devfrom
ruanwenjun:chore/api-task-group-executor-typed-returns

Conversation

@ruanwenjun
Copy link
Copy Markdown
Member

Was this PR generated or assisted by AI?

YES, ops 4.7

Purpose of the pull request

Migrate all 11 TaskGroupService methods from Map<String,Object> returns to typed returns or void with ServiceException, plus the coupled ExecutorService.forceStartTaskInstance which is only invoked from TaskGroupServiceImpl.forceStartTask.

TaskGroupService:

  • createTaskGroup -> TaskGroup
  • updateTaskGroup -> TaskGroup
  • queryAllTaskGroup / queryTaskGroupByStatus / queryTaskGroupByProjectCode -> PageInfo
  • queryTaskGroupById -> TaskGroup (nullable)
  • doQuery -> PageInfo
  • closeTaskGroup / startTaskGroup / forceStartTask / modifyPriority -> void

ExecutorService:

  • forceStartTaskInstance -> void

The private hasProjectPerm helper is replaced with requireProjectPerm which throws ServiceException. Admin users still bypass the project existence check (preserving the prior admin-shortcut semantics) and the non-admin-on-missing-project NPE is replaced with a clean PROJECT_NOT_FOUND error.

ApiExceptionHandler now propagates the controller method's @ResponseStatus to the error response so error and success paths share the same HTTP status code (e.g. POST endpoints stay 201 Created on ServiceException). This is the byte-for-byte fix for putMsg/throw divergence the migration would otherwise introduce — confirmed against TaskGroupControllerTest's real SpringBootTest harness. Two pre-existing tests that asserted the legacy "errors always 200" behaviour are updated to the unified status:

  • AccessTokenControllerTest.testExceptionHandler
  • UsersControllerTest.testCreateUser

ApiExceptionHandlerTest is updated to reflect the new ResponseEntity return type.

No PythonGateway or cross-service callers exist for these methods, so the migration is contained within the api module.

Brief change log

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

….forceStartTaskInstance to typed returns

Migrate all 11 TaskGroupService methods from Map<String,Object> returns to
typed returns or void with ServiceException, plus the coupled
ExecutorService.forceStartTaskInstance which is only invoked from
TaskGroupServiceImpl.forceStartTask.

TaskGroupService:
- createTaskGroup -> TaskGroup
- updateTaskGroup -> TaskGroup
- queryAllTaskGroup / queryTaskGroupByStatus / queryTaskGroupByProjectCode -> PageInfo<TaskGroup>
- queryTaskGroupById -> TaskGroup (nullable)
- doQuery -> PageInfo<TaskGroup>
- closeTaskGroup / startTaskGroup / forceStartTask / modifyPriority -> void

ExecutorService:
- forceStartTaskInstance -> void

The private hasProjectPerm helper is replaced with requireProjectPerm
which throws ServiceException. Admin users still bypass the project
existence check (preserving the prior admin-shortcut semantics) and the
non-admin-on-missing-project NPE is replaced with a clean
PROJECT_NOT_FOUND error.

ApiExceptionHandler now propagates the controller method's
@ResponseStatus to the error response so error and success paths share
the same HTTP status code (e.g. POST endpoints stay 201 Created on
ServiceException). This is the byte-for-byte fix for putMsg/throw
divergence the migration would otherwise introduce — confirmed against
TaskGroupControllerTest's real SpringBootTest harness. Two pre-existing
tests that asserted the legacy "errors always 200" behaviour are
updated to the unified status:
- AccessTokenControllerTest.testExceptionHandler
- UsersControllerTest.testCreateUser

ApiExceptionHandlerTest is updated to reflect the new
ResponseEntity<Result> return type.

No PythonGateway or cross-service callers exist for these methods, so
the migration is contained within the api module.
}

return result;
log.info("Create task group complete, taskGroupName:{}.", taskGroup.getName());

@ExceptionHandler(Throwable.class)
public Result<Object> exceptionHandler(Throwable e, HandlerMethod hm) {
public ResponseEntity<Result<Object>> exceptionHandler(Throwable e, HandlerMethod hm) {
* @return
*/
Map<String, Object> forceStartTaskInstance(User loginUser, int queueId);
void forceStartTaskInstance(User loginUser, int queueId);
* query task group by id (returns null if not found)
*/
Map<String, Object> queryTaskGroupById(User loginUser, int id);
TaskGroup queryTaskGroupById(User loginUser, int id);
* paginated query of task groups
*/
Map<String, Object> doQuery(User loginUser, int pageNo, int pageSize, int userId, String name, Integer status);
PageInfo<TaskGroup> doQuery(User loginUser, int pageNo, int pageSize, int userId, String name, Integer status);
* paginated query of task groups
*/
Map<String, Object> doQuery(User loginUser, int pageNo, int pageSize, int userId, String name, Integer status);
PageInfo<TaskGroup> doQuery(User loginUser, int pageNo, int pageSize, int userId, String name, Integer status);
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 8, 2026

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@ruanwenjun ruanwenjun added this to the 3.4.2 milestone May 8, 2026
@ruanwenjun ruanwenjun added the improvement make more easy to user or prompt friendly label May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend improvement make more easy to user or prompt friendly refactor test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants