OpenSlides / openslides-manage-service

Manage service for OpenSlides 4+
MIT License
4 stars 12 forks source link

reflect change in backend #157

Closed peb-adr closed 2 years ago

peb-adr commented 2 years ago

@normanjaeckel The payload for the user.create action changed in backend. i.e. the provided payload format must change from:

---
first_name: "Ad"
last_name: "Ri"
username: "Ad Ri"
email: "ad@example.com"
default_password: "asd"
is_active: true
organization_management_level: can_manage_organization
committee__management_level:
  1: can_manage
group__ids:
  1: [1, 2]

to:

---
first_name: "Ad"
last_name: "Ri"
username: "Ad Ri"
email: "ad@example.com"
default_password: "asd"
is_active: true
organization_management_level: can_manage_organization
committee__management_level:
  can_manage: [1]
group__ids:
  1: [1, 2]

I'll merge this right away, as it's a very minor change. Tested it as well ofc.

peb-adr commented 2 years ago

@gsiv FYI as well

normanjaeckel commented 2 years ago

@peb-adr I think your change does not work. If you change the proto file you have to re-generated the respective code using the protoc Makefile target. But I think your syntax of the file is wrong. map<string, string> should be correct also for the new format (and that's way it seems to work already. Maybe there is a test ... ;-)

peb-adr commented 2 years ago

@normanjaeckel Ok, I'll provide more info. I have an instance running on the latest tag (4.0.0-dev-20220128-714a03c) Including the manage service and tool running on master (before this PR). Now openslides create-user -f user.yml gives this output:

Error: creating user: calling manage service: calling handler: requesting backend action "user.create": got response "400 BAD REQUEST": "{\"success\": false, \"message\": \"data.committee_$_management_level must not contain {'1'} properties\", \"action_error_index\": 0, \"action_data_error_index\": 0}"

So the backend apparently doesn't accept the request anymore. After a bit of try and error with curl and looking at https://github.com/OpenSlides/openslides-backend/commit/26788dd5e465e54267eddb5a1d338931438b05cb as well as https://github.com/OpenSlides/OpenSlides/commit/714a03c1544e96f22a92550575157c01785e9822 I concluded committee_$_management_level is no longer a map[id -> 'can_manage'] but rather a map['can_manage' -> array[ids] ] (Maybe @r-peschke can confirm this.)

So then I went ahead and changed the request definition in the proto file. I ran make protoc, make go-build, docker build . The restarted the instance using the new manage image. And now the backend accepts the create-user request.

and that's way it seems to work already

So I'm pretty sure this change is needed. My mistake I'm seeing, is that i forgot to also commit the regenerated proto files. Would you agree now, that by pushing them too this PR is fine?

r-peschke commented 2 years ago

@normanjaeckel Ok, I'll provide more info. I have an instance running on the latest tag (4.0.0-dev-20220128-714a03c) Including the manage service and tool running on master (before this PR). Now openslides create-user -f user.yml gives this output:

Error: creating user: calling manage service: calling handler: requesting backend action "user.create": got response "400 BAD REQUEST": "{\"success\": false, \"message\": \"data.committee_$_management_level must not contain {'1'} properties\", \"action_error_index\": 0, \"action_data_error_index\": 0}"

So the backend apparently doesn't accept the request anymore. After a bit of try and error with curl and looking at OpenSlides/openslides-backend@26788dd as well as OpenSlides/OpenSlides@714a03c I concluded committee_$_management_level is no longer a map[id -> 'can_manage'] but rather a map['can_manage' -> array[ids] ] (Maybe @r-peschke can confirm this.)

Yes, you are right, it is a map, that accepts a string from the replacementenum of the field committee$_management and an array of [ids]. The "source of truth" is the wiki, for this case see https://github.com/OpenSlides/OpenSlides/wiki/user.create