nuclear icon indicating copy to clipboard operation
nuclear copied to clipboard

Detect and handle broken config

Open nukeop opened this issue 4 years ago • 17 comments

A broken config file can easily crash the program. Nuclear should be able to detect this problem and either reset the config, or fix the broken parts. Somewhere within the code that loads the config should be a try-catch block that does this.

nukeop avatar Feb 06 '21 00:02 nukeop

can u give more detail like where exactly like where config file

haidang666 avatar Feb 09 '21 05:02 haidang666

The config is managed by electron-store. Loading happens here: https://github.com/nukeop/nuclear/blob/master/packages/main/src/services/store/index.ts

nukeop avatar Feb 09 '21 08:02 nukeop

Hi, Anybody working on this?

mariuscernescu avatar May 14 '21 11:05 mariuscernescu

I don't think anyone is working on it yet, do you want to take it?

nukeop avatar May 14 '21 11:05 nukeop

I will give it a try, thanks.

mariuscernescu avatar May 14 '21 11:05 mariuscernescu

Hi, is this issue still open? Care if I take it?

Pranjal-dew avatar Aug 24 '21 07:08 Pranjal-dew

@Pranjal-dew how are you going to approach this?

nukeop avatar Aug 24 '21 07:08 nukeop

Sure, that would be great. You can find a description of the architecture here: https://nukeop.gitbook.io/nuclear/developer-resources/architecture

And the docs also have a section about contribution guidelines.

nukeop avatar Apr 14 '22 07:04 nukeop

Sure, that would be great. You can find a description of the architecture here: https://nukeop.gitbook.io/nuclear/developer-resources/architecture

And the docs also have a section about contribution guidelines.

On second thought I think I will have to drop the isseu for the time being.

I will reevalute a bit later.

Thanks.

c-jm avatar Apr 14 '22 20:04 c-jm

@nukeop Just to confirm, is anyone working on this?

Andres-Ventura avatar Nov 12 '22 00:11 Andres-Ventura

@nukeop I'm going to work on this.

Andres-Ventura avatar Nov 14 '22 03:11 Andres-Ventura

Great, I was thinking this could be solved better with versioning (this would require storing the version number in the config and allow defining migrations). Other things that will need to be versioned at some point are db schemes and the local library index.

nukeop avatar Nov 14 '22 09:11 nukeop

I see, I'll keep you updated if anything comes up.

Andres-Ventura avatar Nov 14 '22 09:11 Andres-Ventura

@nukeop Can you give me an example of the config breaking? I text you on discord too in the help channel.

Andres-Ventura avatar Dec 03 '22 00:12 Andres-Ventura

As the first step, you can try using JSON.parse (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) and checking if it returns an error.

If it does, fallback to an empty config with default values.

As a next step, we could define a schema for the config (including settings, playlists, and favorites) and check if it complies with it. If there are errors, then that part of the config can either be migrated, or reset. You can use yup for this: https://www.npmjs.com/package/yup

nukeop avatar Dec 10 '22 00:12 nukeop

the config should also contain a "version" key that defines what schema it should follow

nukeop avatar Dec 10 '22 00:12 nukeop

I see, thankyou.

Andres-Ventura avatar Dec 12 '22 05:12 Andres-Ventura