Cannot load MyService.tsx component when monitoringUrl is undefined
slim0 opened this issue · comments
Hi,
We updated onyxia with the 8.16.4 version.
In our configuration, the monitoringUrl
is undefined. In that case, the UI (MyService.tsx component) is not loaded properly. We dig in a bit and it seems that it came from this assert line:
Question: Why asserting something that can be undefined? Maybe some other variables are also impacted.
Sorry about that, and thanks for reporting.
In this particular case, using assertions enables enhanced type safety. It allows TypeScript to understand that if isReady
is true, then helmReleaseFriendlyName
, podNames
, and selectedPodName
are not undefined. I was a bit quick in my assertion, forgetting that monitoringUrl
can be undefined in this region. I should probably use null to represent "not yet fetched" instead of using undefined. It would prevent me from making this kind of mistake again.
More generally, assertions tell TypeScript to "trust me, I know what I'm doing" in cases where the type system cannot follow. Whenever an assertion is incorrect, like here, it makes for a very easily traceable error.
Yes it is.
I'll do a small refactor so this kind of issues may not happen again. Ref #816