btlqql opened a new pull request, #4277:
URL: https://github.com/apache/rocketmq-dashboard/pull/4277

   ## What is the purpose of the change
   
   Blanking the K8s namespace, K8s ID or description of a NameServer registry 
entry had no effect. `NameserverRegistryService.update` replaces every editable 
field of the entry — `name` and `namesrvAddr` are `@NotBlank` in 
`UpdateNameserverRegistryDTO`, and `k8sNamespace`, `k8sId` and `description` 
are copied unconditionally onto the entity — so the request is a full 
replacement of the entry it addresses:
   
   ```java
   entity.setK8sNamespace(command.getK8sNamespace());
   entity.setK8sId(command.getK8sId());
   entity.setDescription(command.getDescription());
   ...
   int updated = nameserverMapper.updateById(entity);
   ```
   
   Two things then line up to lose the clear. The cluster page's registry edit 
dialog submits a blanked optional field as an absent one 
(`web/src/pages/cluster/index.tsx:255-257` builds the payload with 
`k8sNamespace: values.k8sNamespace || undefined` and the same for `k8sId` and 
`description`), and MyBatis-Plus `updateById` omits null entity fields 
(`FieldStrategy.NOT_NULL`; there is no `update-strategy` override in 
`application.yml`), so those three columns were dropped from the SET clause and 
kept their previous values.
   
   Clearing was therefore unreachable through the API: `null` meant "leave the 
column alone" (accidentally), and there is no clear flag as in general 
settings. The save reported success, `update` re-read the row and returned the 
retained value, and the dialog displayed the old text again with no error — 
which is where the operator notices, because a stale `k8sId` cannot be dropped 
from the UI.
   
   The cleared optional columns are now assigned explicitly, mirroring the ACL 
clear-columns fix in #3342, while the non-null columns keep going through 
`updateById`. `name` / `namesrvAddr` validation, duplicate-name handling and 
the concurrent-delete checks are unchanged.
   
   ## Brief changelog
   
   - `NameserverRegistryService.update`: assign `k8s_namespace`, `k8s_id` and 
`description` explicitly when the request carries no value for them, because 
`updateById` skips null entity fields.
   - `NameserverRegistryServiceTest`: two new cases — a request that omits the 
three optional columns clears them through an explicit assignment; a request 
that submits them issues no extra assignment.
   
   ## Verification
   
   Red first, on the unmodified implementation with only the new tests added:
   
   ```
   mvn -f server/pom.xml -B -DskipITs -Dtest=NameserverRegistryServiceTest 
-DfailIfNoTests=false test
   [ERROR] Tests run: 22, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 
1.135 s <<< FAILURE! -- in 
org.apache.rocketmq.studio.cluster.nameserver.NameserverRegistryServiceTest
   [ERROR]   
NameserverRegistryServiceTest.updateShouldClearOptionalColumnsThatTheRequestOmitsTest:368
   [ERROR] Tests run: 22, Failures: 1, Errors: 0, Skipped: 0
   [INFO] BUILD FAILURE
   ```
   
   (`...:368` is the `verify(nameserverMapper).update(isNull(), 
captor.capture())` assertion — no assignment was issued for the cleared 
columns.)
   
   Green after the change:
   
   ```
   mvn -f server/pom.xml -B -DskipITs -Dtest=NameserverRegistryServiceTest 
-DfailIfNoTests=false test
   [INFO] Tests run: 22, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 
1.126 s -- in 
org.apache.rocketmq.studio.cluster.nameserver.NameserverRegistryServiceTest
   [INFO] BUILD SUCCESS
   ```
   
   Whole backend suite on this branch (`mvn -f server/pom.xml -B -DskipITs 
test`): `Tests run: 2153, Failures: 5, Errors: 5, Skipped: 0`. I also ran the 
same command on the unmodified base commit `6c24d2ed`: `Tests run: 2151, 
Failures: 5, Errors: 5` with the identical 10 failing test ids — 8 need a POSIX 
`sh` CLI that this Windows machine does not have (`CliAgentProviderTest`, 
`ClaudeCodeAgentProviderTest`) and 2 are 
`AuthCorsIntegrationTest.shouldRejectNonAdminMutationBeforeControllerExecution` 
/ `shouldStillRejectAnonymousProtectedRequests`, which also fail on the base 
and are aligned separately in #4217. No other test moved.
   
   The DB path itself was not exercised end to end here (no MySQL in this 
environment); the regression test asserts the assignment that the fix issues, 
in the same style as the accepted ACL fix in #3342.
   
   Fixes #4274


-- 
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]

Reply via email to