openwisp-controller icon indicating copy to clipboard operation
openwisp-controller copied to clipboard

[bug] If default templates contain a flaw, auto-registration will fail

Open nemesifier opened this issue 7 years ago • 5 comments

If the default templates have a conflict with one another which causes the resulting NetJSON configuration to fail the schema validation, auto-registration will fail with 500 internal server error.

A possible solution would be the following:

  • if the current template being saved is flagged as default
  • before saving, create a NetJSON configuration from all the default templates using the same backend and try to validate it against the schema used, if the validation fails, trigger a django ValidationError

We must provide a way to extend this behaviour, since downstream apps will need more complex validation rules (openwisp-controller will have to check default templates for each organization if the default template being edited is "shared").

nemesifier avatar Apr 07 '18 18:04 nemesifier

@nemesisdesign I am not able to reproduce this bug, I was doing following: I created two templates Enabled by default with various timezones. I created device configuration with these templates enabled by default, but I haven't seen any errors in my browser's console and in my terminal where is running django server. While watching preview of configuration before saving and after saving I only saw that one template is overriding another one in both cases without any error.

I was using chromium browser for it.

strang1ato avatar Jul 02 '19 10:07 strang1ato

Creating two templates with different timezones will not reproduce this error.

Try creating two default template with an interface which is exactly identical and will trigger a schema error.

nemesifier avatar Jul 18 '19 14:07 nemesifier

@nemesisdesign I followed your tips, but still I don't see any error. Can you check is that error still occuring on the latest version of django-netjsonconfig?

strang1ato avatar Aug 10 '19 20:08 strang1ato

Reopened based on comment here: https://github.com/openwisp/django-netjsonconfig/commit/ffd53171c8db3f98559d934320e52575dd98da09#commitcomment-38440339

atb00ker avatar Apr 12 '20 11:04 atb00ker

Thanks @atb00ker and @nepython! :+1:

nemesifier avatar Apr 13 '20 19:04 nemesifier