InseeFrLab / onyxia

🔬 Data science environment for k8s

Home Page:https://onyxia.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot load MyService.tsx component when monitoringUrl is undefined

slim0 opened this issue · comments

commented

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:

assert(monitoringUrl !== undefined);

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.

commented

@garronej is it fixed ? i guess yes

Yes it is.

I'll do a small refactor so this kind of issues may not happen again. Ref #816