Repository: provectus/kafka-ui
Issue: FE: Topics: Do not send properties which are not defined explicitly
Labels: type/bug
good first issue
scope/frontend
status/accepted
severity/medium

### Issue submitter TODO list

- [X] I've looked up my issue in [FAQ](https://docs.kafka-ui.provectus.io/faq/common-problems)
- [X] I've searched for an already existing issues [here](https://github.com/provectus/kafka-ui/issues)
- [X] I've tried running `master`-labeled docker image and the issue still persists there
- [X] I'm running a supported version of the application which is listed [here](https://github.com/provectus/kafka-ui/blob/master/SECURITY.md)

### Describe the bug (actual behavior)

Hi
I create a topic without any 'Custom parameters', in order to set the topic with cluster configurations.
however, It is created with TOPIC_CUSTOM_PARAMS values, not cluster configuration values.


### Expected behavior

_No response_

### Your installation details

1. hash commit: 9549f68

### Steps to reproduce

1. 
I set cluster configurations at AWS.
![스크린샷 2023-07-12 오전 9 23 15](https://github.com/provectus/kafka-ui/assets/50516754/14ff521a-8a12-4981-ace9-f8bff2548994)
'line 14' means that the default retention bytes of topic, when created without a specific retention bytes value, is 1073741824 bytes (1GB) 

2.
It works well when I create a topic with kafka cli (```./kafka-topics.sh --create --replication-factor=1 --partitions=1 --topic brokertest1 --bootstrap-server sth:9092```)

3.
however, when I create a topic at kafka-ui without any custom parameter, it means to set a topic with the default cluster config,
It doesn't work and retention.bytes is set to '-1'
![스크린샷 2023-07-12 오전 9 34 18](https://github.com/provectus/kafka-ui/assets/50516754/80807267-1bcb-456e-a351-dbc82fefe174)


![252823352-05cea9d8-701b-4bb5-a8cf-2059aa0940ae](https://github.com/provectus/kafka-ui/assets/50516754/7a2728a5-590a-4b1d-bce3-a61b391330b9)




### Screenshots

_No response_

### Logs

_No response_

### Additional context

I tried to solve the issue, and found that ```configs``` at ```formatTopicCreation``` is related.
https://github.com/provectus/kafka-ui/blob/f124fa632d10aaad7d79c9ee0b00f32922079972/kafka-ui-react-app/src/lib/hooks/api/topics.ts#L86C5-L86C5

the config values are from constants ```TOPIC_CUSTOM_PARAMS```
https://github.com/provectus/kafka-ui/blob/f124fa632d10aaad7d79c9ee0b00f32922079972/kafka-ui-react-app/src/lib/constants.ts#L22C1-L22C1

Each value means a default input value in a custom parameter form.
![스크린샷 2023-07-12 오전 10 07 42](https://github.com/provectus/kafka-ui/assets/50516754/e5985c67-561e-4441-af5c-0e98dc875326)

however, below five configs are set with constants, so expected cluster default config does not work.

solved:
After commenting out like below, 
topic creation w/o custom parameters works well.
- custom cluster config works well : ex) retention.bytes = 1073741824 bytes
- kafka default config works well: ex) cleanup.policy = delete
```
  const configs = {
//     'cleanup.policy': cleanupPolicy,
//     'retention.ms': retentionMs.toString(),
//     'retention.bytes': retentionBytes.toString(),
//     'max.message.bytes': maxMessageBytes.toString(),
//     'min.insync.replicas': minInSyncReplicas.toString(),
    ...Object.values(customParams || {}).reduce(topicReducer, {}),
  };
```

We actually run MSK with cluster level config now.
but now, default config is not work so we have to set the values to each topic manually.

I think removing five lines can be a solution.. but there may be other purposes of the code.
could your team review this issue?

thank you.

Issue comments:
@Haarolean when `retention.bytes` (Max size on disk) is not set implicitly - frontend **should not** pass this parameter to backend. 

@Haarolean hi, can i pr like i said? or does it still need to be reviewed? thank you.
@p-eye the proper solution is described here: https://github.com/provectus/kafka-ui/issues/4030#issuecomment-1652008533
if you can do just that, feel free to raise a PR
@Haarolean
although i captuered my test only for `retention.bytes`,  i think other 4 properties also should not be passed to backend because of the same reason. (when a specific value is not assigned, a config should be set with the default, or cluster level value...)
i will raise the PR for five properties, thank you
- `cleanup.policy`
- `retention.ms`
- `max.message.bytes`
- `min.insync.replicas`

ref)
https://docs.confluent.io/platform/current/installation/configuration/broker-configs.html

Pull request review comments:

Patch that resolved the issue:
diff --git a/kafka-ui-react-app/src/components/Topics/New/New.tsx b/kafka-ui-react-app/src/components/Topics/New/New.tsx
index a8d2600a43a..c7528fb99ae 100644
--- a/kafka-ui-react-app/src/components/Topics/New/New.tsx
+++ b/kafka-ui-react-app/src/components/Topics/New/New.tsx
@@ -15,7 +15,7 @@ enum Filters {
   PARTITION_COUNT = 'partitionCount',
   REPLICATION_FACTOR = 'replicationFactor',
   INSYNC_REPLICAS = 'inSyncReplicas',
-  CLEANUP_POLICY = 'Delete',
+  CLEANUP_POLICY = 'cleanUpPolicy',
 }
 
 const New: React.FC = () => {
diff --git a/kafka-ui-react-app/src/lib/hooks/api/topics.ts b/kafka-ui-react-app/src/lib/hooks/api/topics.ts
index f06b6a87670..00d08bc66b8 100644
--- a/kafka-ui-react-app/src/lib/hooks/api/topics.ts
+++ b/kafka-ui-react-app/src/lib/hooks/api/topics.ts
@@ -76,7 +76,6 @@ const formatTopicCreation = (form: TopicFormData): TopicCreation => {
     partitions,
     replicationFactor,
     cleanupPolicy,
-    retentionBytes,
     retentionMs,
     maxMessageBytes,
     minInSyncReplicas,
@@ -86,7 +85,6 @@ const formatTopicCreation = (form: TopicFormData): TopicCreation => {
   const configs = {
     'cleanup.policy': cleanupPolicy,
     'retention.ms': retentionMs.toString(),
-    'retention.bytes': retentionBytes.toString(),
     'max.message.bytes': maxMessageBytes.toString(),
     'min.insync.replicas': minInSyncReplicas.toString(),
     ...Object.values(customParams || {}).reduce(topicReducer, {}),
diff --git a/kafka-ui-react-app/src/redux/interfaces/topic.ts b/kafka-ui-react-app/src/redux/interfaces/topic.ts
index 153002240a1..bdc25ee0c60 100644
--- a/kafka-ui-react-app/src/redux/interfaces/topic.ts
+++ b/kafka-ui-react-app/src/redux/interfaces/topic.ts
@@ -44,7 +44,6 @@ export interface TopicFormData {
   minInSyncReplicas: number;
   cleanupPolicy: string;
   retentionMs: number;
-  retentionBytes: number;
   maxMessageBytes: number;
   customParams: {
     name: string;


Test patch: