Repository: provectus/kafka-ui
Issue: HTTP 414 with a big partitions list selected
Labels: type/bug
scope/frontend
status/accepted
status/confirmed

<!--

Don't forget to check for existing issues/discussions regarding your proposal. We might already have it.
https://github.com/provectus/kafka-ui/issues
https://github.com/provectus/kafka-ui/discussions

-->

**Describe the bug**
running on latest master:
messages do not load under messages tab for certain topics in a given cluster. all settings are default (serde, pagination).
The response in the browser console is 414 (url too long). The problematic endpoint is `t/opics/mainOsyTrigger/messages?filterQueryType`
notes: 
* This kafka cluster has 240 partitions, maybe that's the problem.
* This problem doesn't occur on release `v0.4.0`

The request URL looks like this: `https:/my-kafka-ui/topics/mainOsyTrigger/messages?filterQueryType=STRING_CONTAINS&attempt=1&limit=100&seekDirection=FORWARD&keySerde=null&valueSerde=null&seekType=BEGINNING&seekTo=0%3A%3A3074090%2C1%3A%3A2873466%2C2%3A%3A3057371%2C3%3A%3A3224533%2C4%3A%3A3238047%2C5%3A%3A2882461%2C6%3A%3A2973712%2C7%3A%3A3036851%2C8%3A%3A2998608%2C9%3A%3A3081134%2C10%3A%3A3432678%2C11%3A%3A3032894%2C12%3A%3A2932963%2C13%3A%3A3021701%2C14%3A%3A3093426%2C15%3A%3A3142236%2C16%3A%3A3346479%2C17%3A%3A3042457%2C18%3A%3A3188474%2C19%3A%3A3122717%2C20%3A%3A3338328%2C21%3A%3A3002992%2C22%3A%3A3117563%2C23%3A%3A3066825%2C24%3A%3A3024334%2C25%3A%3A3090044%2C26%3A%3A2875326%2C27%3A%3A3071587%2C28%3A%3A3073475%2C29%3A%3A3353610%2C30%3A%3A3060803%2C31%3A%3A2985938%2C32%3A%3A3300810%2C33%3A%3A3043026%2C34%3A%3A3088143%2C35%3A%3A3094591%2C36%3A%3A3148360%2C37%3A%3A2972083%2C38%3A%3A3222534%2C39%3A%3A3014068%2C40%3A%3A3102879%2C41%3A%3A2964547%2C42%3A%3A2936218%2C43%3A%3A2996908%2C44%3A%3A3061150%2C45%3A%3A2790067%2C46%3A%3A2970756%2C47%3A%3A3039456%2C48%3A%3A3097037%2C49%3A%3A3156340%2C50%3A%3A3238510%2C51%3A%3A2962902%2C52%3A%3A3066628%2C53%3A%3A2975306%2C54%3A%3A3180922%2C55%3A%3A3410678%2C56%3A%3A2992099%2C57%3A%3A3155103%2C58%3A%3A2938148%2C59%3A%3A2929215%2C60%3A%3A3142161%2C61%3A%3A3202679%2C62%3A%3A3503614%2C63%3A%3A3113890%2C64%3A%3A2980539%2C65%3A%3A3055035%2C66%3A%3A2922145%2C67%3A%3A3094968%2C68%3A%3A3229233%2C69%3A%3A3032187%2C70%3A%3A2960532%2C71%3A%3A3200119%2C72%3A%3A3072256%2C73%3A%3A3336365%2C74%3A%3A3071080%2C75%3A%3A3091609%2C76%3A%3A3012113%2C77%3A%3A3096383%2C78%3A%3A2929622%2C79%3A%3A3095415%2C80%3A%3A3043199%2C81%3A%3A3283358%2C82%3A%3A3056106%2C83%3A%3A2983369%2C84%3A%3A2916423%2C85%3A%3A3275715%2C86%3A%3A3296668%2C87%3A%3A3394228%2C88%3A%3A3098087%2C89%3A%3A3030158%2C90%3A%3A3150636%2C91%3A%3A2878705%2C92%3A%3A3039426%2C93%3A%3A3150403%2C94%3A%3A3048218%2C95%3A%3A3001379%2C96%3A%3A3163979%2C97%3A%3A3299770%2C98%3A%3A3071348%2C99%3A%3A3103185%2C100%3A%3A3078464%2C101%3A%3A3136160%2C102%3A%3A3218327%2C103%3A%3A2886828%2C104%3A%3A3032169%2C105%3A%3A3003752%2C106%3A%3A2896270%2C107%3A%3A3160299%2C108%3A%3A3103092%2C109%3A%3A3107543%2C110%3A%3A2892965%2C111%3A%3A3158000%2C112%3A%3A2940465%2C113%3A%3A3019562%2C114%3A%3A3383091%2C115%3A%3A3052166%2C116%3A%3A3092634%2C117%3A%3A3461752%2C118%3A%3A3173274%2C119%3A%3A3071851%2C120%3A%3A3106930%2C121%3A%3A3111206%2C122%3A%3A3060124%2C123%3A%3A3156639%2C124%3A%3A3130224%2C125%3A%3A2902996%2C126%3A%3A2973758%2C127%3A%3A3292917%2C128%3A%3A3021322%2C129%3A%3A3178655%2C130%3A%3A3142298%2C131%3A%3A2952581%2C132%3A%3A3099713%2C133%3A%3A3097531%2C134%3A%3A2949911%2C135%3A%3A3120310%2C136%3A%3A2943906%2C137%3A%3A3081907%2C138%3A%3A3197362%2C139%3A%3A2958921%2C140%3A%3A3022182%2C141%3A%3A3129833%2C142%3A%3A2963757%2C143%3A%3A3223688%2C144%3A%3A2991264%2C145%3A%3A3021824%2C146%3A%3A3309025%2C147%3A%3A3281467%2C148%3A%3A3032307%2C149%3A%3A2872527%2C150%3A%3A2996964%2C151%3A%3A3036588%2C152%3A%3A3334637%2C153%3A%3A3346481%2C154%3A%3A3095406%2C155%3A%3A3035255%2C156%3A%3A3162874%2C157%3A%3A3153442%2C158%3A%3A3084418%2C159%3A%3A3212934%2C160%3A%3A2866368%2C161%3A%3A2918106%2C162%3A%3A3122933%2C163%3A%3A3372647%2C164%3A%3A3493517%2C165%3A%3A3229364%2C166%3A%3A3084963%2C167%3A%3A3076450%2C168%3A%3A3126261%2C169%3A%3A3132226%2C170%3A%3A2989424%2C171%3A%3A2955585%2C172%3A%3A2980134%2C173%3A%3A2991709%2C174%3A%3A3436223%2C175%3A%3A3059177%2C176%3A%3A2949204%2C177%3A%3A3060454%2C178%3A%3A3067493%2C179%3A%3A3053507%2C180%3A%3A3080837%2C181%3A%3A3068181%2C182%3A%3A3080689%2C183%3A%3A3120516%2C184%3A%3A3202197%2C185%3A%3A3049898%2C186%3A%3A3150783%2C187%3A%3A3093330%2C188%3A%3A3168716%2C189%3A%3A2981076%2C190%3A%3A2897306%2C191%3A%3A3045436%2C192%3A%3A3114719%2C193%3A%3A3153424%2C194%3A%3A3338991%2C195%3A%3A3001310%2C196%3A%3A3163588%2C197%3A%3A3143609%2C198%3A%3A3321556%2C199%3A%3A3096641%2C200%3A%3A3138570%2C201%3A%3A3305132%2C202%3A%3A3083234%2C203%3A%3A2866230%2C204%3A%3A3239104%2C205%3A%3A2932237%2C206%3A%3A3026534%2C207%3A%3A3180500%2C208%3A%3A3246722%2C209%3A%3A3025870%2C210%3A%3A3090457%2C211%3A%3A3122387%2C212%3A%3A2812894%2C213%3A%3A3111089%2C214%3A%3A3255140%2C215%3A%3A3064275%2C216%3A%3A3239711%2C217%3A%3A2770812%2C218%3A%3A3160334%2C219%3A%3A3347422%2C220%3A%3A3116640%2C221%3A%3A3239702%2C222%3A%3A2832341%2C223%3A%3A3096067%2C224%3A%3A3371181%2C225%3A%3A3328135%2C226%3A%3A3220448%2C227%3A%3A3035209%2C228%3A%3A3096710%2C229%3A%3A3017020%2C230%3A%3A3054040%2C231%3A%3A3075303%2C232%3A%3A2964717%2C233%3A%3A2915869%2C234%3A%3A3099099%2C235%3A%3A3019695%2C236%3A%3A2826167%2C237%3A%3A3046179%2C238%3A%3A3065352%2C239%3A%3A3045407`

**Set up**
deploying latest master branch using a k8s deployment manifest, passing configs as env variables. 


**Steps to Reproduce**
Steps to reproduce the behavior:

1. open kafka-ui from browser
2. navigate to cluster --> topics --> meesages tab
3. nothing is displayed, error in browser console (described above)

**Expected behavior**
messages are loaded correctly



Issue comments:
Hello there wanisfahmyDE! 👋

Thank you and congratulations 🎉 for opening your very first issue in this project! 💖

In case you want to claim this issue, please comment down below! We will try to get back to you as soon as we can. 👀
@Mgrdich we can skip this param if all the partitions are selected

cc: @iliax 
Needs a fix.

#3568 
https://github.com/provectus/kafka-ui/pull/3582#discussion_r1161564606
#3525

Pull request review comments:

Patch that resolved the issue:
diff --git a/kafka-ui-react-app/src/components/Topics/Topic/Messages/Filters/Filters.tsx b/kafka-ui-react-app/src/components/Topics/Topic/Messages/Filters/Filters.tsx
index 096a714c4ee..08e4aed6912 100644
--- a/kafka-ui-react-app/src/components/Topics/Topic/Messages/Filters/Filters.tsx
+++ b/kafka-ui-react-app/src/components/Topics/Topic/Messages/Filters/Filters.tsx
@@ -231,18 +231,21 @@ const Filters: React.FC<FiltersProps> = ({
         props.seekType = SeekType.TIMESTAMP;
       }
 
-      props.seekTo = selectedPartitions.map(({ value }) => {
-        const offsetProperty =
-          seekDirection === SeekDirection.FORWARD ? 'offsetMin' : 'offsetMax';
-        const offsetBasedSeekTo =
-          currentOffset || partitionMap[value][offsetProperty];
-        const seekToOffset =
-          currentSeekType === SeekType.OFFSET
-            ? offsetBasedSeekTo
-            : timestamp?.getTime();
-
-        return `${value}::${seekToOffset || '0'}`;
-      });
+      if (selectedPartitions.length !== partitions.length) {
+        // not everything in the partition is selected
+        props.seekTo = selectedPartitions.map(({ value }) => {
+          const offsetProperty =
+            seekDirection === SeekDirection.FORWARD ? 'offsetMin' : 'offsetMax';
+          const offsetBasedSeekTo =
+            currentOffset || partitionMap[value][offsetProperty];
+          const seekToOffset =
+            currentSeekType === SeekType.OFFSET
+              ? offsetBasedSeekTo
+              : timestamp?.getTime();
+
+          return `${value}::${seekToOffset || '0'}`;
+        });
+      }
     }
 
     const newProps = omitBy(props, (v) => v === undefined || v === '');


Test patch: