Repository navigation
fix: preserve alert receiver fields during partial updates (#6711) - #7038
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new selective MyBatis update binds accessToken as jdbcType=TINYINT despite being a String/VARCHAR, which can cause incorrect updates or runtime SQL type conversion errors.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR addresses #6711 by preventing partial alert receiver updates from overwriting omitted columns with NULL, switching the admin update path to a selective MyBatis update and making enable/matchAll nullable so “not provided” can be preserved.
Changes:
- Use
updateByPrimaryKeySelectivefor alert receiver updates and add the corresponding mapper method + dynamic SQL. - Convert
enableandmatchAllfrom primitivebooleanto nullableBoolean, and update mapping/tests accordingly. - Make alert dispatch filtering null-safe (
Boolean.TRUE.equals(...)) and preservetruedefaults on create in the service layer.
File summaries
| File | Description |
|---|---|
| shenyu-alert/src/main/java/org/apache/shenyu/alert/model/AlertReceiverDTO.java | Make enable/matchAll nullable to support selective updates without implicit false/default writes. |
| shenyu-admin/src/test/java/org/apache/shenyu/admin/transfer/AlertTransferTest.java | Update mapping assertions for nullable Booleans and add null-mapping coverage. |
| shenyu-admin/src/test/java/org/apache/shenyu/admin/service/AlertReceiverServiceTest.java | Verify selective update usage and ensure full-column update isn’t called. |
| shenyu-admin/src/main/resources/mappers/alert-receiver-sqlmap.xml | Add updateByPrimaryKeySelective dynamic SQL for partial updates. |
| shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/AlertTransfer.java | Update DTO/DO mapping for nullable enable/matchAll. |
| shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AlertReceiverServiceImpl.java | Default enable/matchAll to true on create and switch update to selective update. |
| shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AlertDispatchServiceImpl.java | Make dispatch filtering null-safe for nullable Booleans. |
| shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/AlertReceiverDO.java | Make persisted enable/matchAll nullable to preserve omitted fields. |
| shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/AlertReceiverMapper.java | Add updateByPrimaryKeySelective to the mapper interface. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| <if test="email != null">email = #{email,jdbcType=VARCHAR},</if> | ||
| <if test="hookUrl != null">hook_url = #{hookUrl,jdbcType=VARCHAR},</if> | ||
| <if test="wechatId != null">wechat_id = #{wechatId,jdbcType=VARCHAR},</if> | ||
| <if test="accessToken != null">access_token = #{accessToken,jdbcType=TINYINT},</if> |
Aias00
left a comment
There was a problem hiding this comment.
Approved as PMC (Aias00). Coherent, well-scoped fix with regression tests; green CI, mergeable. Reviewed the diff.
Aias00
left a comment
There was a problem hiding this comment.
The selective update maps accessToken with jdbcType=TINYINT even though access_token and the Java field are strings. Updating a DingTalk token can fail conversion or persist the wrong value. Please use VARCHAR and add a selective-update regression test for accessToken.
Map accessToken as VARCHAR in the insert, full update, and selective update statements to match the Java field and database column. Add a mapper regression test that selectively updates a DingTalk access token, reads it back, and checks that an unrelated field is preserved.
Aias00
left a comment
There was a problem hiding this comment.
Reviewed current head 7f102f6243dd.
The prior CHANGES_REQUESTED item is fixed in current head source. The PR now preserves omitted receiver fields through a selective update, keeps create defaults for nullable booleans, updates dispatch filtering to be null-safe, and includes mapper/service/transfer coverage for the changed behavior.
Validation: exact-head targeted Maven reactor tests passed on Java 17.
./mvnw -pl shenyu-admin -am test -Dtest=AlertReceiverMapperTest,AlertReceiverServiceTest,AlertTransferTest -Dsurefire.failIfNoSpecifiedTests=false -Drat.skip=true -Djacoco.skip=true -DskipRemoteResources=true -Dmaven.javadoc.skip=trueGitHub still reports failing checks: e2e, e2e-case (e2e-logging-rabbitmq-compose, shenyu-e2e-case-logging-rabbitmq, :shenyu-examples-http). This review does not claim those checks have passed.
|
Ping on state: this PR is approved on the code, but the required checks are red and it cannot be merged yet. The failing jobs are No code change is expected from you. Once the shared e2e problem is resolved, please rerun the failed jobs (or push a trivial rebase) so the required checks go green, and this can be merged. |
|
@juicewcode This PR is approved, but 7 checks are red: I inspected these lanes today and they fail for infrastructure reasons rather than on the diff — the Please rebase onto |
|
@juicewcode — a correction to the note I left here yesterday. The failures on this branch all predate the fix, so nothing in your change is implicated.
That means the red checks recorded here are stale. A push — an empty commit or a rebase, whichever is easier — re-runs them against the current baseline. I would not spend time reading the old logs. For the |
…iver-partial-update-
Fixes #6711
Summary
updateByPrimaryKeywithupdateByPrimaryKeySelectivefor alert receiver updates.enableandmatchAllfrom primitivebooleanto nullableBoolean.truewhen creating a new alert receiver.Test
AlertReceiverServiceTestto verify selective updates and prevent calls to the full-column update method.AlertTransferTestfor nullable Boolean mapping.enableandmatchAllvalues.Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true.