{"record":{"id":"8da20c57fcb11d32","repo":"provectus/kafka-ui","slug":"no-command-registered-with-id","errorCode":null,"errorMessage":"No command registered with id ","messagePattern":"No command registered with id ","errorType":"validation","errorClass":"ValidationException","httpStatus":400,"severity":"error","filePath":"kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/ksql/KsqlServiceV2.java","lineNumber":47,"sourceCode":"  }\n\n  private final Cache<String, KsqlExecuteCommand> registeredCommands =\n      CacheBuilder.newBuilder()\n          .expireAfterWrite(1, TimeUnit.MINUTES)\n          .build();\n\n  public String registerCommand(KafkaCluster cluster,\n                                String ksql,\n                                Map<String, String> streamProperties) {\n    String uuid = UUID.randomUUID().toString();\n    registeredCommands.put(uuid, new KsqlExecuteCommand(cluster, ksql, streamProperties));\n    return uuid;\n  }\n\n  public Flux<KsqlResponseTable> execute(String commandId) {\n    var cmd = registeredCommands.getIfPresent(commandId);\n    if (cmd == null) {\n      throw new ValidationException(\"No command registered with id \" + commandId);\n    }\n    registeredCommands.invalidate(commandId);\n    return cmd.cluster.getKsqlClient()\n        .flux(client -> client.execute(cmd.ksql, cmd.streamProperties));\n  }\n\n  public Flux<KsqlTableDescriptionDTO> listTables(KafkaCluster cluster) {\n    return cluster.getKsqlClient()\n        .flux(client -> client.execute(\"LIST TABLES;\", Map.of()))\n        .flatMap(resp -> {\n          if (!resp.getHeader().equals(\"Tables\")) {\n            log.error(\"Unexpected result header: {}\", resp.getHeader());\n            log.debug(\"Unexpected result {}\", resp);\n            return Flux.error(new KsqlApiException(\"Error retrieving tables list\"));\n          }\n          return Flux.fromIterable(resp.getValues()\n              .stream()\n              .map(row ->","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/provectus/kafka-ui/blob/83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/ksql/KsqlServiceV2.java#L29-L65","documentation":"KsqlServiceV2.execute(commandId) looks up the previously registered command (containing cluster, ksql text and stream properties) in a Caffeine cache of registered commands. If the id is absent — never registered or already evicted/expired — a ValidationException('No command registered with id <id>') is thrown.","triggerScenarios":"Calling execute with a commandId that was never returned by the register/execute flow, one already invalidated by a previous execute call, or one expired from the size/time-bounded cache.","commonSituations":"Client retrying with an old commandId after cache eviction; execute called twice with the same id (first call invalidates it); service restart wiping in-memory cache while clients hold old ids; wrong id string.","solutions":["Re-submit the original ksql command to obtain a fresh commandId, then execute with it","Use each commandId exactly once — execute invalidates it after lookup","Check for service restarts that cleared the in-memory registeredCommands cache","Log/capture the commandId immediately after registration and verify it is passed unchanged"],"exampleFix":"// before\nString id = registerCommand(cluster, ksql);\nexecute(id);\nexecute(id); // second call: id already invalidated\n// after\nString id = registerCommand(cluster, ksql);\nexecute(id); // single use\n// for a second run: re-register\nString id2 = registerCommand(cluster, ksql);\nexecute(id2);","handlingStrategy":"try-catch","validationCode":"// Track commandId lifecycle: use-once\nSet<String> consumed = ConcurrentHashMap.newKeySet();\nboolean usable = commandId != null && !consumed.contains(commandId);\nif (!usable) throw new IllegalStateException(\"commandId already used or unknown: \" + commandId);","typeGuard":null,"tryCatchPattern":"try {\n  Flux<KsqlResponseTable> tables = ksqlServiceV2.execute(commandId);\n} catch (ValidationException e) {\n  if (e.getMessage().startsWith(\"No command registered with id\")) {\n    log.warn(\"commandId {} unknown/expired — re-registering command\", commandId);\n    String newId = ksqlServiceV2.registerCommand(cluster, ksql, streamProperties);\n    tables = ksqlServiceV2.execute(newId);\n  } else { throw e; }\n}","preventionTips":["Treat commandIds as single-use: register -> execute once","Re-register after any kafka-ui restart (cache is in-memory)","Don't persist commandIds across sessions; store the ksql text instead","Capture and use the id returned by the register call, never a guessed value"],"tags":["ksql","cache","command-id","state"],"backgroundTag":"entity-not-found","analyzedSha":"83b5a60cc08501b570a0c4d0b4cdfceb1b88d6b7","analyzedAt":"2026-09-08T04:35:39.002Z","contentChangedAt":"2026-09-08T04:35:39.002Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}