Repository: provectus/kafka-ui
Issue: 404 at first call "Statistic" page
Labels: type/bug
scope/frontend
status/accepted
status/confirmed
severity/low
area/ux

Dear developers,

Found an issue with topic statistics page
How to reproduce:
1. First login in system.
2. Select topic and statistics tab then.
3. "404 Not found" label will appear at the rigth bottom of the page.

Error appears only at first loading of the "Statistics" page. Next calls of the page error label does not appear.
"Statistics" function is working as usual by the way
Version of UI is v0.6.1 ef0dacb

![404-statistics](https://user-images.githubusercontent.com/19203188/228463688-05a5bbe0-4300-4797-83e3-0b8beac18d91.PNG)


Issue comments:
Hello there khudyakovan! 👋

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. 👀
Hello @Haarolean, Can you assign me to this issue?
Thank you for assigning this issue to me.

I want to run the app with the configuration "kafka-ui-auth-context.yaml" file so I can access to the login button and test the problem.

I have been trying to run my app with this configuration. Can you please help me with this?

Thanks

@inanc-can you don't exactly need that compose, as you don't need authentication at all. You can run any of the compose examples.
<img width="1792" alt="Screenshot 2023-04-20 at 19 04 24" src="https://user-images.githubusercontent.com/55583718/233437672-83f8c20c-707d-4539-8967-0a0f1ad68ab8.png">

In this example which I reached with the "kafka-ui % docker run -it -p 8080:8080 -e DYNAMIC_CONFIG_ENABLED=true provectuslabs/kafka-ui", There is no option to Log In.

I assumed that I should first need to "Log In" and Topic > Statistics to test the case.

If it is wrong please explain me how should I proceed later.
@inanc-can you don't need to log in unless there is an authentication mechanism in place.
The app you run has no clusters configured, either add one manually via "configure new cluster" or run a compose which does have one, i.e. `docker-compose -f ./documentation/compose/kafka-ui.yaml up -d`.
Thank you for responding quickly.

I have recreated the situation that causes this problem.

How can I rerun the project so that my changes would appear on my localhost ?
(In a React Project, I could reach this by saving the project then it would reload, so that you understand what I mean)

Thanks
@inanc-can
2. set the vite proxy as described [here](https://github.com/provectus/kafka-ui/tree/master/kafka-ui-react-app#proxying-api-requests-in-development), pointing at your container's 8080 port to use it as backend
1. launch the frontend via npm start
Hallo @Haarolean 

This request causes the issue :
<img width="566" alt="Screenshot 2023-04-25 at 18 01 28" src="https://user-images.githubusercontent.com/55583718/234335713-acc972ef-cca6-44e9-8c56-4b78096c98e9.png">

Is there a way to get a reload every time I change the API (as it happens in the front-end), so I can take a look if I can fix it through the backend?

Would you happen to have any other suggestions?
@inanc-can it's a pure frontend issue. 404 is _expected_ if there's no statistics result already available, meaning that there's nothing to display just yet until the next run is started & completed. We just need to remove the red warning upon 404 there.
@inanc-can any updates?
I have spent a considerable amount of time attempting to resolve the issue. 404 Error is caught at App.tsx in "const query Client". Although I have spent some time on it, I believe that the functionality is working properly since it displays an error message when an error occurs.


@inanc-can I've already mentioned that 404 is expectable there, so we don't have to display it.
See #3964 if you're interested how the solution looks.

Pull request review comments:

Patch that resolved the issue:
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 a87673368dd..f06b6a87670 100644
--- a/kafka-ui-react-app/src/lib/hooks/api/topics.ts
+++ b/kafka-ui-react-app/src/lib/hooks/api/topics.ts
@@ -304,6 +304,11 @@ export function useTopicAnalysis(
       useErrorBoundary: true,
       retry: false,
       suspense: false,
+      onError: (error: Response) => {
+        if (error.status !== 404) {
+          showServerError(error as Response);
+        }
+      },
     }
   );
 }


Test patch: