Skip to content

[Studio][Bug] Creating a K8s certificate accepts blank or padded identities that the update API rejects #4299

Closed as not planned

Description

@btlqql

1. Symptom

POST /api/k8s-certs/create accepts certificate identities that POST /api/k8s-certs/update refuses,
and stores them verbatim:

  • a whitespace-only issuer (" ") or k8sId/cluster is accepted and persisted without trimming,
    while the same value sent to the update API is rejected with 400 Certificate issuer cannot be blank;
  • the stored value keeps its padding, so k8sId / cluster / issuer read back as " new-tls-cert ".

The bundled web dialog happens to send values.k8sId.trim() and values.cluster.trim()
(web/src/pages/cluster/certs.tsx:104-105), so the inconsistency only shows for any other API client -
and the server is the component that owns the contract.

2. Root cause

server/src/main/java/org/apache/rocketmq/studio/cluster/k8s/K8sCertService.java:81-95

String issuer = command.getIssuer();
List<String> san = command.getSan();
...
K8sCertVO cert = K8sCertVO.builder()
        .k8sId(command.getK8sId())
        .cluster(command.getCluster())
        .type(type)
        .issuer(issuer)

createCert passes the submitted identities straight through, while updateCert routes the same three
fields through normalizeOptionalIdentity (:120-122, :175-184), which trims and rejects a blank
value. CreateCertDTO's @NotBlank constraints accept surrounding whitespace, so they do not close the
gap either.

3. Impact

  • A certificate row can be created in a state the update API cannot produce, so the two write paths
    disagree about what a valid identity is.
  • Padded identities are stored and returned padded, which breaks later exact-match lookups and makes the
    inventory look like it contains duplicates ("prod" and " prod").
  • Fixing it afterwards requires an update call that a client written against the create contract may not
    expect to fail.

4. Reproduction

  1. POST /api/k8s-certs/create with
    {"k8sId": " new-tls-cert ", "cluster": " test-cluster ", "type": "TLS", "issuer": " vault "}.
  2. Response: 200 with k8sId " new-tls-cert " and issuer " vault ".
  3. POST /api/k8s-certs/update with {"id": <id>, "issuer": " "}: 400 Certificate issuer cannot be blank.

5. Expected behaviour

  • createCert normalises k8sId, cluster and issuer exactly like updateCert: trimmed, blank
    rejected with 400 Certificate <field> cannot be blank.
  • A value derived from a supplied certPem is unaffected: when a certificate is uploaded, its parsed
    issuer/SAN still win over the submitted ones.

Activity

  1. RockteMQ-AI commented on Sep 15, 2026

    @RockteMQ-AI

    Issue Evaluation

    Category: bug | Status: Under Review

    Thank you for reporting this. It has been classified as a potential bug and is queued for code-level verification against the current codebase.

    If confirmed, an automated fix proposal may be generated. You can reply with /approve to proceed, or provide additional context to help with verification.


    Automated evaluation by RockteMQ-AI

  2. github-actions commented on Sep 23, 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