ioBroker.js-controller icon indicating copy to clipboard operation
ioBroker.js-controller copied to clipboard

[Feature] check object properties (during object creation)

Open mcm1957 opened this issue 8 months ago • 4 comments

js controller should check state configuration when cretaing or extending a state. Especially role shoul dbe checked against data type and read/write settings.

I.e. role indocator is incompatible with write=true or type=string

When checking ONLY during creation/extending the number od log entries should be acceptable.

Config could be either hardcoded or extendable by using a cached schema from online service. The later approach would allow to check if a role is defined at all too.

mcm1957 avatar Oct 29 '23 17:10 mcm1957

As there has been some concern about performance impact (at telegram) I would like to state;

The check should ONLY be performed when really creating or modifying a state - NOT at every access. As states should not be created over and over the impact should be acceptable.

Its totally ok to miss modifications done by users to existing states - its not the goal to detect such changes, the goal is to give feeback to developers to write correct state definitions. As states are likely to be created dynamically, its impossible to check them by repo checker.

mcm1957 avatar Nov 20 '23 16:11 mcm1957

So it is more like an extended object creation check, we already have them when objects are created or extended. We would need to extend that by a check which checks if write, read and type match the state definitions.

We could maybe create a file which holds like Record<string, {write: boolean, read: boolean, type: ioBroker.AllowedStateType}> as a single point of truth. Meaning creating the docs automatically out of it (not on dev releases only real releases) + using it as validation, so docs + validation would be in sync.

foxriver76 avatar Nov 20 '23 16:11 foxriver76

Well The technical details are know by you vest.

I would suggest to check

Type Role Read write

Against eachbother. And of course unknow roles must be allowed unless we can gurantte a very fast update of roles without explicit user action. Updating with js-controller releases would be to slow as users ste likely several releases behind.

mcm1957 avatar Nov 20 '23 17:11 mcm1957

I fixed the wording in at least headline ... it is about objects ... not states

Apollon77 avatar Nov 21 '23 10:11 Apollon77