Skip to content

[Studio][Bug] A topic remark cannot be cleared through POST /api/topics/update #4272

Closed as not planned

Description

@btlqql

1. Symptom

POST /api/topics/update (TopicController.updateTopic -> ApacheInstanceProvider.updateTopic -> RocketMQAdminClientImpl.updateTopic) cannot remove a topic's stored remark.

A blank remark is accepted (HTTP 200) and the response echoes the blank value, but the rmq_instance_topic row keeps the previous remark, so the next topic list load shows the old text again. Editing a remark to a different non-blank value works; only clearing it is lost.

2. Root cause

server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQAdminClientImpl.java:382-384

if (StringUtils.hasText(topic.getRemark())) {
    existing.setRemark(topic.getRemark());
}

The cached row is only written when the submitted remark has text, so a blank submission is treated exactly like an omitted one. TopicVO.remark / UpdateTopicDTO.remark are plain nullable strings with no validation and no separate clear flag (unlike clearApiKey / clearDingtalkSigningSecret in general settings), so a blank remark is the only way a caller can express "this topic has no remark".

Clearing is a two-part problem: assigning null to the entity field would not persist either, because MyBatis-Plus updateById omits null entity fields (FieldStrategy.NOT_NULL). That mechanism is already documented and fixed for the ACL user/rule columns in #3342, and it has to be handled explicitly on this path as well.

3. Impact

  • The remark column of a managed topic is write-once: it can be created and edited, never cleared. Operators have to recreate the topic or edit MySQL directly.
  • The endpoint lies: the 200 response carries the cleared value while the database still holds the old one.
  • The update path is the one the create dialog's edit mode is wired to (POST /api/topics/update is documented in docs/api-spec.md §5.4 and implemented for all three providers, and web/src/pages/instance/topic.tsx is being wired to it in feat(topic): edit topic configuration from the topic page #4249), so the UI cannot clear a remark either.

4. Reproduction

  1. Create a topic with a remark, or update one to have a remark.
  2. POST /api/topics/update with {"name": "<topic>", "instanceId": "<instance>", "remark": ""}.
  3. Response: 200, remark is empty.
  4. Reload the topic list (GET /api/topics) or SELECT remark FROM rmq_instance_topic WHERE name = '<topic>': the previous remark is still there.

5. Expected behaviour

  • An omitted remark (null) keeps the stored value, which is what the existing partial-update comment in updateTopic describes.
  • A submitted blank remark clears it (the column must become NULL).
  • The response reports the persisted remark instead of the submitted one.
  • CreateTopicDTO/UpdateTopicDTO stay unchanged; no behavioural change for callers that submit a real remark.

Activity

  1. RockteMQ-AI commented on Sep 13, 2026

    @RockteMQ-AI

    Issue Evaluation

    Category: bug | Status: Confirmed

    The reported issue has been verified against the current codebase.

    Root Cause: Same mechanism as the admin credential ref issue — MyBatis-Plus updateById uses FieldStrategy.NOT_NULL by default, which omits null entity fields from the SET clause. When TopicService.updateTopic copies the incoming remark into the entity, a blank remark becomes null after StringUtils.isBlank check, and updateById silently drops the null assignment. The column retains its previous value.

    Impact: Operators cannot clear a topic's remark through the standard update API. The UI shows the old remark until the next reload. This is a data inconsistency issue that affects topic metadata management.

    Severity: Medium — metadata inconsistency, not security-critical but affects operator workflow.

    Suggested Fix: Use an UpdateWrapper or LambdaUpdateWrapper in the repository layer to explicitly set remark = NULL when the incoming remark is blank. This is the same pattern needed for #4273 and the prior fixes for ACL columns (#3342).

    Note: This issue shares the same root cause pattern as #4273. A single fix at the repository layer (introducing a proper null-aware update strategy) could address both issues and prevent future recurrences for other nullable columns.

    An automated fix proposal will be generated. Reply /approve to proceed with PR generation.


    Automated evaluation by github-manager

  2. RockteMQ-AI commented on Sep 13, 2026

    @RockteMQ-AI

    Issue Evaluation

    Category: type/bug | Status: Confirmed

    The POST /api/topics/update endpoint cannot clear a topic's remark because the update path treats blank values as "skip this field." This is the same class of issue as #4274 and #4273 — empty string updates are silently ignored. The fix should propagate blank values through to the underlying admin operation.


    Automated evaluation by github-manager

  3. added 2 commits that reference this issue on Sep 15, 2026
    86447a8
    87c4c7f
  4. github-actions commented on Sep 21, 2026

    @github-actions

    This issue has been automatically closed because there has been no activity for 7 days. If you believe this issue is still relevant, please reopen it with updated information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions