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

   ## What is the purpose of the change
   
   An instance's admin credential reference could not be removed. 
`InstanceService.updateInstance` maps a blank submitted reference to `null` 
through `normalizeCredentialRef` (`InstanceService.java:561-563`), so a blank 
is an explicit clear:
   
   ```java
   if (!cloudInstance && instance.getAdminCredentialRef() != null) {
       
updated.setAdminCredentialRef(normalizeCredentialRef(instance.getAdminCredentialRef()));
   }
   ```
   
   The updated instance is then written by `instanceRepository.save(updated)` 
(`InstanceService.java:607`), and `MybatisPlusInstanceRepository.save` issues 
`instanceMapper.updateById(entity)` (`MybatisPlusInstanceRepository.java:122`). 
MyBatis-Plus `updateById` omits null entity fields (`FieldStrategy.NOT_NULL`; 
there is no `update-strategy` override in `application.yml`), so the null 
reference never reaches the SET clause: the stored `admin_credential_ref` 
survived the update while the service returned a VO whose reference was null.
   
   The user-visible effect is the same one described in #3342 for the ACL 
columns: the edit dialog accepts the clear, the API answers 200 with 
`adminCredentialRef: null`, the page replaces its row with that response 
without refetching (`web/src/pages/instance/index.tsx:447-455`), and the 
reference reappears on the next list load. An operator can therefore set or 
change an external admin credential reference but never remove it.
   
   The repository is the only layer that can express the clear: 
`InstanceRepository.save` is called just twice, from 
`InstanceService.createInstance` (insert) and `InstanceService.updateInstance` 
(update), so the update branch now assigns `admin_credential_ref` explicitly 
when the incoming VO carries no reference.
   
   ## Brief changelog
   
   - `MybatisPlusInstanceRepository.save`: after the entity update, assign 
`admin_credential_ref` explicitly when the saved instance has no reference, 
because `updateById` skips null entity fields.
   - `MybatisPlusInstanceRepositoryTest`: two new cases — a null reference 
clears the column through an explicit assignment; a submitted reference 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=MybatisPlusInstanceRepositoryTest 
-DfailIfNoTests=false test
   [ERROR] Tests run: 18, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 
1.140 s <<< FAILURE! -- in 
org.apache.rocketmq.studio.instance.MybatisPlusInstanceRepositoryTest
   [ERROR]   
MybatisPlusInstanceRepositoryTest.saveShouldClearTheAdminCredentialRefWhenTheUpdateRemovesIt:254
   [ERROR] Tests run: 18, Failures: 1, Errors: 0, Skipped: 0
   [INFO] BUILD FAILURE
   ```
   
   (`...:254` is the `verify(instanceMapper).update(isNull(), 
captor.capture())` assertion — no assignment was issued for the cleared column.)
   
   Green after the change:
   
   ```
   mvn -f server/pom.xml -B -DskipITs -Dtest=MybatisPlusInstanceRepositoryTest 
-DfailIfNoTests=false test
   [INFO] Tests run: 18, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 
1.199 s -- in 
org.apache.rocketmq.studio.instance.MybatisPlusInstanceRepositoryTest
   [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 #4273


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