lll-peanut opened a new pull request, #6535:
URL: https://github.com/apache/shenyu/pull/6535
git push -u origin fix/tag-create-parent-tag-npe
### 3. 创建 PR
打开:
https://github.com/apache/shenyu/compare/master...lll-peanut:shenyu:fix/tag-create-parent-tag-npe?expand=1
(或 apache/shenyu → Pull requests → New pull request → compare across
forks,base apache/shenyu/master,head
lll-peanut/shenyu/fix/tag-create-parent-tag-npe)
标题:
fix: validate parent tag existence when creating child tag
描述:
Fixes #6520
## What's changed
- TagServiceImpl.createInner now validates the parent tag exists when
parentTagId is not the root id. A missing parent tag throws
ValidFailException("parent tag is not found") instead of passing null to
buildExtParamByParentTag.
## Why
Creating a child tag with a non-existent parentTagId made
tagMapper.selectByPrimaryKey return null, then
buildExtParamByParentTag(null) called parentTagDO.getId() and threw
NullPointerException (internal 500) instead of a clear validation error.
## Tests
- Added TagServiceTest.testCreateWithNonExistentParentTag: create with a
missing parentTagId must throw ValidFailException. It failed with
`NullPointerException: ... "parentTagDO" is null` before the fix.
- `mvn -pl shenyu-admin test -Dtest=TagServiceTest` → 7 tests passed.
## Manual verification
- POST /tag with a parentTagId that does not exist.
- Before fix: NPE in admin log, generic error response.
- After fix: response message "parent tag is not found", no NPE.
Make sure that:
- [X] You have read the [contribution
guidelines](https://shenyu.apache.org/community/contributor-guide).
- [X] You submit test cases (unit or integration tests) that back your
changes.
- [X] Your local test passed `./mvnw clean install
-Dmaven.javadoc.skip=true`.
--
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]