ruanwenjun opened a new pull request, #18229:
URL: https://github.com/apache/dolphinscheduler/pull/18229
<!--Thanks very much for contributing to Apache DolphinScheduler, we are
happy that you want to help us improve DolphinScheduler! -->
## Was this PR generated or assisted by AI?
YES, ops 4.7
## Purpose of the pull request
Refactor 7 TaskDefinitionService methods from Map<String, Object> to typed
return / void + ServiceException, with cascading updates to controller,
PythonGateway and unit test:
- queryTaskDefinitionByName(...): TaskDefinition
- updateTaskWithUpstream(...): Long (the updated task code)
- switchVersion(...): void
- deleteByCodeAndVersion(...): void
- queryTaskDefinitionDetail(...): TaskDefinitionVO
- genTaskCodeList(Integer): List<Long>
- releaseTaskDefinition(...): void
The private updateTask helper now throws ServiceException for every error
path; it still returns null for the "task body unchanged" case so the public
method can short-circuit when both the body and upstream relations are
unchanged. As a side effect this fixes a latent bug in updateTaskWithUpstream
where any error from the helper was silently overridden with SUCCESS whenever
the new and existing upstream code sets happened to match (e.g.
TASK_DEFINE_NOT_EXIST returned 200 OK). No test covered that edge case.
A small private helper requireProjectAndWritePerm replaces the inline
hasProjectAndWritePerm(Map) call sites; ProjectService remains untouched and
will be migrated last in the #18224 series.
HTTP wire format is preserved: ApiExceptionHandler converts ServiceException
to the same Result(code, msg) shape that BaseController.returnDataList(map)
produced; success paths use Result.success(data) matching the prior JSON body
byte-for-byte.
Py4J boundary is preserved: PythonGateway.genTaskCodeList still returns
Map<String, Object> with the same {STATUS, MSG, DATA_LIST} keys, now
constructed in the wrapper from the service's typed return.
Part of the migration series tracked by #18224.
## Brief change log
<!--*(for example:)*
- *Add maven-checkstyle-plugin to root pom.xml*
-->
## Verify this pull request
<!--*(Please pick either of the following options)*-->
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:
<!--*(example:)*
- *Added dolphinscheduler-dao tests for end-to-end.*
- *Added CronUtilsTest to verify the change.*
- *Manually verified the change by testing locally.* -->
(or)
## Pull Request Notice
[Pull Request
Notice](https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md)
If your pull request contains incompatible change, you should also add it to
`docs/docs/en/guide/upgrade/incompatible.md`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]