Javascript error on group modify

Groups created with the old NethGUI opened into Cockpit generates this error:

UsersGroups.vue:2910 Uncaught TypeError: Cannot read property 'editable' of undefined
    at UsersGroups.vue:2910
    at Function.<anonymous> (nethserver.js:102)
    at s (cockpit.min.js:963)
    at cockpit.min.js:975
    at n (cockpit.min.js:881)

The problem is caused by the result of this command that do not contains editable parameter.

[root@server ~]# echo '{"role":"test","action":"role"}' | /usr/bin/sudo /usr/libexec/nethserver/api/system-roles/read | jq
  "system": [],
  "applications": []

A correct one is like this:

[root@mail ~]# echo '{"role":"produzione","action":"role"}' | /usr/bin/sudo /usr/libexec/nethserver/api/system-roles/read | jq
  "system": [],
  "status": {
    "editable": 1
  "applications": []

@giacomo Do you think it can be helpful I proceed to open the bug and investigate on it?

I think it can be enough to modify lines 68-70 of system-roles/read api as follow:

if ($counter == 0) { #we have no match, this role is not known
        print encode_json({"system" => [],"status" => {'editable' => 1},"applications" => []});

Am I wrong?

1 Like

It’s a cosmetic bug: the UI behaves correctly but the Javascript console displays an error.
I think the editable flag doesn’t make sense could be ignored for groups.

Yes, you are right but I’ll point out to you two things:

  • it’s not only a console error: Cockpit shows on the right “Ooops” red that can “scare” Sysadmin :slight_smile:
  • when you save the group, flag editable is set

@giacomo I don’t want to stress you :smiley: do you think we need to proceed with bug fix or we close it here?

Sorry, I didn’t reply :slight_smile: Proceed with the bugfix, especially because Cockpit displays the “Ooops”.

Thank you! :wink:

1 Like

Opened bug and PR

1 Like